Live data from Hacker News

What's the one Linux command you wish you knew years ago?

reddit.com

21–30 of 216 posts

Re: What's the one Linux command you wish you knew years ago?

#25

I'm not sure why, but it was a while before I ran across du -h. Not sure how I ever did without it! Oh, and "sudo !!". Definitely key, along with "& disown".

"!ssh" to run the most recent ssh command without having to type out the long list of arguments I use and the host name.

Re: What's the one Linux command you wish you knew years ago?

#27
post #3

100% agree with CTRL-R. It changed my life. Others that I love: screen, pdsh, perl -pi -e 's/find/replace/g' *.txt redis-cli's new ability to have piped in data be the last argument of a command. vim -o file1.txt file2.txt file3.txt (opening multiple files with vim) Using vim instead of less as a pager: cat file.txt | vim -

sed -i does the same thing as perl -pi. Though I've not encountered a system that doesn't have both.

Re: What's the one Linux command you wish you knew years ago?

#28
post #25

I'm not sure why, but it was a while before I ran across du -h. Not sure how I ever did without it! Oh, and "sudo !!". Definitely key, along with "& disown".

"!ssh" to run the most recent ssh command without having to type out the long list of arguments I use and the host name.

It helps to put your most frequent entries in ~/.ssh/config

  Host somewhere
  HostName somewhere.example.com
  User username
  IdentityFile ~/.ssh/somewhere_key.pub

Re: What's the one Linux command you wish you knew years ago?

#30
post #13

Earlier quoted context omitted.

You'll want to quote .java so the shell doesn't interpret it as a glob, and find doesn't use GNU style flags. You can also pass wc the filenames directly like this: wc -l $(find . -name '*.java')

That has different semantics (it prints one line per file) and can have line length limitations. This has the same semantics as the parent's version, but without line length issues. find . -name \*.java -exec cat {} + | wc -l

Note that the + may not be portable. I know it doesn't work on older Solaris versions (Also, find may or may not split the files it finds into multiple invocations.
Post reply on HN