Hacker News new | ask | show | jobs
by koeselitz 5752 days ago
As far as these little shorthands go, you've left out the one I use most all day long; the ever-handy !:-, which means 'the last command minus the final argument':

$ 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 !!

$

1 comments

I like the !:-, even though it's super ugly. It's the perfect complement to alt+. !! is a classic, but the article mentions it.