15 Linux Bash History Expansion Examples You Should Know

2012-03-02 116 words 1 min read

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

author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it