|
|
|
|
|
by cmurphycode
5752 days ago
|
|
Here are some of my other favorites: ^foo^bar replaces the foo in the last command with bar example: less setup.conf, ^less^vim alt+. recalls the last argument of the last command (in emacs mode, anyway) example: less setup.conf, vim alt+. As mentioned, Ctrl+R is great for history searching. Repeatedly pressing Ctrl+R goes to the next result, and you can use the arrow keys to edit. cd - goes to the last directory. It handles most of the use cases for pushd and popd. |
|
$ 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 !!
$