Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

!$ (short for !!:$)

Passes last argument on the command line. In general, the whole paragraph on HISTORY EXPANSION in the bash manual is a must read.

A few ones from the moreutils package:

- vipe : manually edit the data in the middle of a pipe.

- vidir : treat a directory and its files as a text file. Does renames and deletions.

- sponge : when you're doing modification on a file in a pipe, and want the output to be to this file (file will be scrambled without sponge).

It has others, very useful tools, but I won't spoil them all.



alt-. or (ESC .) does something similar, but can be pressed repeatedly to keep going back further in history in case the argument you want isn't on the most recent command.

!! is short for the previous command, but you can do !-2$ to get the last argument from the 2nd last command, or !cp$ to get the last argument from the most recent cp command. Or !cp:2 to get the 2nd argument to the most recent cp command. !# refers to the current command being entered (in zsh, don't know about bash).

Basically I second Aissen's recommendation to read up on history expansion. Super useful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: