Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] Re: useful bash tricks thread

At the risk of being called an oldie, I keep using !-notation since
the early tcsh days. E.g. "!$" or !:2-3.

You can also use things like


to fetch the parameters of the latest less command.

I can't type alt-> because alt-shift is my keyboard language-switching
combination, so I don't know how this compares with good old

Other useful stuff:

^x^y will replace the first "x" on the previous line by "y". Use a
third "^" after "y" if it contains space. It's actually a short for

Where !!:s comes handy is to replace globally: !!gs/x/y/ will replace
ALL of the "x"'s on last line by "y"'s.

Then again - you can type "!command" or "!-3" to use another history
line as a basis.

And one last thing, related to security - if you type a sensitive
string on the command line and get it into your history, use "history
-d" to delete this line.