15 Linux Bash History Expansion Examples You Should Know

Screenshot of a sample Bash session, taken on ...
Image via Wikipedia

Here is a nice link on BASH History Expansion. There are lot of examples in this page and some of them might be quite useful. But here are my list of favourites:

!!

This is probably the most used one by me. This will repeat the last command. And this works even in conjunction with other commands like

sudo !!

And the second most used one is :

!$

This puts the last parameter of the last executed command. So, you could do something like:

ls a/very/long/path/with/file/name
vi !$
Enhanced by Zemanta