Friday, June 14, 2013

Small tips on bash

Famous tips but I didn't know before.

1. Oh, I forgot to type sudo and got permission error...
Type
$ sudo !!

Here, !! refers to the previous command issued.


2. I don't wanna type that lengthy command or arguments or whatever again...
Type first several letters of the command and hit ^r (Control - r). If the completed command is not what you want, type ^r again and again until you get what you want.

^r searches command history and complete the command line. You can see your command line history with "history" command. Each command line history has an index, and a command can be reissued by typing ! followed by a index number. (e.g. $ !1)

No comments:

Post a Comment