[There are times when history is not the best way to repeat commands. Here, Jerry gives an example where a few well-chosen aliases can make a sequence of commands, all run on the same file, even easier to execute. -TOR]
While I was writing the articles for this book, I needed to look through a set of files, one by one, and run certain commands on some of those files. I couldn't know which files would need which commands, or in what order. So I typed a few temporary aliases on the C shell command line. (I could have usedon sh-like shells.) Most of these aliases run commands, but they could run any UNIX command (compilers, debuggers, printers, and so on).
alias h 'set f="\!*";co -p -q "$f" | grep NOTE'%
alias o 'co -l "$f"'%
alias v 'vi "$f"'%
alias i 'ci -m"Fixed title." "$f"'
The h alias stores the filename in a
h ch01_summaryNOTE: Shorten this paragraph: %
oRCS/ch01_summary,v -> ch01_summary revision 1.3 (locked) done %
v"ch01_summary" 23 lines, 1243 characters ...
Typing a new h command stores a new filename.
If you always want to do the same commands on a file, you can store all the commands in one alias:
alias d 'set f="\!*"; co -l "$f" && vi "$f" && ci "$f"'%