Live data from Hacker News

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

reddit.com

201–210 of 216 posts

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

#201
post #197

I wonder, how do you remember all the command line options? Recently I had this thought: maybe those people who can remember the options actually are autistic (don't know the proper word, that thing many geeks are deemed to be), and I am not. Remembering command line options might be like knowing large prime numbers within seconds. But I am also interested in memory techniques like the Loki method. Perhaps some good…

Umm, we just use the commands a lot. Doing something 12 hours a day for 10 years tends to leave some imprints on your memory.

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

#202
post #4

For me it was definitely find. I went through a ton of contortions to replicate its behavior several times before somebody knowledgeable clued me in. Also, `` and $(). Find combined with one of these is great. One of my favorite one-liners (I even figured it out myself :)) is: cat `find . --name *.java` | wc -l

In zsh:

    cat **/*.java | wc -l

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

#203

It's not a command but it is still useful. When you are typing a long command and you realize that you need to do other command or set of commands first, usually you type ctrl + c to cancel it. By default it does not save in the history. If you put # (comment the command) in front of the command (you can do it quickly with Ctrl + a #) and then you can use Ctrl + r to get it back. I'm sure there are other ways to save…

Even better: just type \ (line continuation) at point that you realize that you need to do something else first. Then hit Ctrl-c to cancel once you get to the new line.

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

#204
post #48

Nobody knows this: the bash extension $ diff -u Internally, bash creates a pipe and passes /dev/fd/XXX to the main command.

Just diff the two directories. $ ls a b a: 1 2 3 4 b: 1 2 3 # Yours: $ diff -u Maybe I'm missing something?

Yes, you are because the example was contrived. The point is that process substitution (as it is called) is available on systems that support named pipes. You could think of better uses for it.

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

#205
post #4

For me it was definitely find. I went through a ton of contortions to replicate its behavior several times before somebody knowledgeable clued me in. Also, `` and $(). Find combined with one of these is great. One of my favorite one-liners (I even figured it out myself :)) is: cat `find . --name *.java` | wc -l

In zsh: cat **/*.java | wc -l

Bash got this functionality in v4.

It's not as useful as find.

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

#206

Earlier quoted context omitted.

The 'help' command is exactly what you're looking for -- e.g., 'help disown' will describe the 'disown' command. Definitely beats searching the entire bash man page for the command you want (which is what I did for far too long, until I found out about 'help').

Yeah, but it often isn't as long as a real man page. Plus for some reason zsh doesn't have it!

There's always google you know :D. The point is to know what to look for:

$ help "*"

will print out all shell built ins (list help for them). And if the short description is not enough, go google for each.

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

#207

emacs --daemon (or after you start emacs, M-x server-start). This starts up the emacs server, so that it preserves your open files, and you can start new emacs instances immediately with emacsclient. (I actually symlink emacsclient to vi since it loads as fast as vi, which was one of the weakest points of emacs for me.) Very useful if you are using a remote box (like a vps) as your dev environment.

And if you are VIM user, you can do the same :D:

    $ vim -h | grep -i server
       --remote 	Edit  in a Vim server if possible
       --remote-silent   Same, don't complain if there is no server
       --remote-wait-silent   Same, don't complain if there is no server
       --remote-send 	Send  to a Vim server and exit
       --remote-expr 	Evaluate  in a Vim server and print result
       --serverlist		List available Vim server names and exit
       --servername 	Send to/become the Vim server 
    $

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

#208
post #196
post #52

Earlier quoted context omitted.

Many comments seem to be shell- and bash-related. Perhaps the thread exposes how difficult to read the bash manpage is. On my system, the bash 4.1 manpage is 41026 words long, or about 80 pages. Manpages are most useful to me when they are short and to-the-point so I can find what I am looking for before I lose interest in skimming through an 80 page book.

On my MacBook the manpages scroll hellishly slow and there are no "Page Down" keys (maybe there is some key combo? I don't know). I end up googling for the manpages on the web instead most of the time...

f and b will do page scrolling in the man viewer.

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

#209
post #169

Earlier quoted context omitted.

And for you crazy people on python3.. python3 -m http.server

[ward@hathor ~]$ ls -l /usr/bin/python lrwxrwxrwx 1 root root 7 Sep 5 00:45 /usr/bin/python -> python3 Arch default

I think he covered Arch users when he said "crazy people" :)

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

#210

Earlier quoted context omitted.

Dollar-paren expansion beats backticks for being nestable. E.g.: I like dumping temporary files with timestamps: some-command-to-generate-log > /tmp/log-$( date +%Y%m%d-%H%M%S ) Now, if I want to wrap that in a larger loop -- say, iterating over a number of files or parameters: command $( expansion one $( expansion 2 )) Works With backticks you'd have to do escapes: command `expansion 1 \`expansion 2\` ` ... which ge…

I like to use (for GNU date at least): $ date -Iseconds 2011-11-21T10:56:17+0000 because it requires less typing. The ISO 8601 standard format. -Is, -Im, -Ih, and -Id allow you to change the displayed resolution. Bizarrely, this doesn't seem to be documented in my version of date (coreutils 8.10).

A lot of the date documentation is unfortunately in info only. Debian (and derived distros) do a good job of updating the manpages.

That said, I can't find "-I" documented anywhere.

What I like about the timestamp I use is that it's semantic but sorts lexically as well. Though yours does as well. Hrm.

Post reply on HN