15 Linux Bash History Expansion Examples You Should Know
2012-03-02
116 words
1 min read
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 !$
Related articles
- Linux hardware details. (amit-agarwal.co.in)
- A Very Useful Linux Command For Unix/Linux System Admins (hakanyildirgan.com)
- imabonehead: hypergeometric ” Stupid Bash Expansion Trick (hypergeometric.com)
Related Articles:
- 2010/12/23 Bash Script Beautifier
- 2011/05/16 Unix shell script for removing duplicate files
- 2011/01/05 Shell Scripting
- 2011/03/14 cd across parallel directories
- 2011/01/31 Ranking of the most frequently used commands
Authored By Amit Agarwal
Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.