I am starting to learn some Regex, therefore I use this command repeatedly:
grep pattern /usr/share/dict/american-english
Only the part with pattern changes, so I have to write the long expression "/usr/share/dict/american-english" again and again.
Someone made the remark that it is possible to expand an argument of a command from the command history by typing cryptic character combinations instead of the full expression. Could you tell me those cryptic character combinations ?
bash
,dash
,zsh
,mksh
, andksh
shells (at least, that I know about) will all recognize the$_
last arg special parameter (some do so only in interactive mode, though). It just expands like a variable:grep somepattern filename; grep otherpattern "$_"
. You can usually see its contents in the output ofset
.