|Even before the interactive command line editor of tcsh (and other unofficial versions of csh and zsh and bash and others) existed, csh had command line editing based on a line editor paradigm. This facility still exists today in almost all of the "modern" shells, and is worth learning. It's often a lot faster to type in a correction or modification to a command than to edit it appropriately!
Here I'll try to summarise some of the idioms I commonly use.
- As N-wing already noded, this just expands to the last command.
- Expands to the last command starting with "abc".
- Expands to command #123 in the history list.
- Expands to word 4 of the last command starting with "abc". Words are counted from , so !abc:0 is that line's command, and !abc:3 is its third parameter.
- !!:$ or !$
- Expands to the last word of the last command. Often used in idioms like this:
% some_tricky_command prm1 prm2 ... > /long/path/to/output
% grep 'regexp' !$
% more !$
- Expands to the last command starting with "abc", with the first occurrence of pattern replaced by replacement. pattern is unfortunately not a regexp.
- Short for !:s/wrong/right.
- Expands to the last command starting with "abc", with all occurrences of pattern replaced by replacement.
Teach your fingers to type these in automatically. It's a great way to semi-automate many tedious command-line tasks.