11.9 Running a Series of Commands on a File[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 used shell functions (10.9 ) on sh -like shells.) Most of these aliases run RCS (20.14 ) commands, but they could run any UNIX command (compilers, debuggers, printers, and so on). % The h
alias stores the filename in a
shell variable (6.8
)
.
Then it runs a command on that file.
What's nice is that, after I use h
once, I don't need to type the
filename again.
Other aliases get the filename from % 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: % The
- |
|