Let's start with some obvious ways to run commands more than once:
Type !! (Section 30.8) to repeat the previous command line, or repeat a cycle of commands with !-n (Section 30.9)
Press the up-arrow key (Section 30.14) or a vi- or Emacs-style editing command
Copy and paste the command line with your mouse (Section 28.10)
Whether each of those methods will work depends on the shell you're using and whether you have copy-and-paste built into your interface. All of those methods force you to take some action before each command line repeats -- pressing the up-arrow key, for instance. That lets you control exactly when each command runs.
The next four articles show automated ways to repeat a command a certain number of times. You can "mix and match" some parts of different articles -- the tips on read and sleep, for instance. Each article follows on to the one before, so we suggest glancing through all of them:
In C shells, repeat a single command with the repeat command.
Methods for Bourne-type shells use more-general shell features.
An offbeat method that works with all shells is to output multiple commands using jot.
The shells' for and foreach loops (Section 28.9) can vary the commands they run by picking a string (a word, for instance) from a list of strings.
To repeat a command and display its output in the same place on the screen -- so it's easy to spot differences over time -- try vis (Section 28.11).
Finally, remember that you aren't stuck with the login shell you chose. If you want a feature that your shell doesn't have, you can use another shell temporarily by typing its name (like csh), running the commands you need, then typing exit to go back to your original shell.
-- JP
Copyright © 2003 O'Reilly & Associates. All rights reserved.