Tutorial by Examples

You can use the !$ to reduce repetition when using the command line: $ echo ping ping $ echo !$ ping You can also build upon the repetition $ echo !$ pong ping pong $ echo !$, a great game pong, a great game Notice that in the last example we did not get ping pong, a great game because...
Interaction with the history # List all previous commands history # Clear the history, useful if you entered a password by accident history -c Event designators # Expands to line n of bash history !n # Expands to last command !! # Expands to last command starting with "text&qu...
Press controlr and type a pattern. For example, if you recently executed man 5 crontab, you can find it quickly by starting to type "crontab". The prompt will change like this: (reverse-i-search)`cr': man 5 crontab The `cr' there is the string I typed so far. This is an incremental s...
$ mkdir backup_download_directory && cd !#:1 mkdir backup_download_directory && cd backup_download_directory This will substitute the Nth argument of the current command. In the example !#:1 is replaced with the first argument, i.e. backup_download_directory.
$ mplayer Lecture_video_part1.mkv $ ^1^2^ mplayer Lecture_video_part2.mkv This command will replace 1 with 2 in the previously executed command. It will only replace the first occurrence of the string and is equivalent to !!:s/1/2/. If you want to replace all occurrences, you have to use !!:gs...
$ apt-get install r-base E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? $ sudo !! sudo apt-get install r-base [sudo] password for <user>:

Page 1 of 1