Re:Understanding Bash History
by cmurphycode on Friday September 17, 2010 @05:38PM
(#1702924)
I like the !:-, even though it's super ugly. It's the perfect complement to alt+. !! is a classic, but the article mentions it.
$ cat ~/my_huge_dataset.csv | tr '\|' ',' >> testing.csv
$ !:- for_real_this_time.csv
>> cat ~/my_huge_dataset.csv | tr '\|' ',' >> for_real_this_time.csv
$
This is really, really handy for me - particularly in two situations: first, when (like above) I'm testing a command by outputting to a random off-server file first; and second (the more often) when I'm running the exact same process on a dozen different files, just pasting the filenames onto the command line. It's really handy to be able to use !:- all the way down for every one.
Oh, and theres's also this: !! - which means 'the last command exactly.' That can be handy, too:
$ rm /usr/lib/libutil.so
>> m: cannot remove `libutil.so': Permission denied
$ sudo !!
$