History Substitutions

[Although most of the examples here use echo to demonstrate clearly just what is going on, you'll normally use history with other UNIX commands. -JP]

The exclamation point (!) is the C shell's default () history substitution character. (It's used in bash, too.) This allows you to recall previously entered commands and re-execute them without retyping. The number of commands saved is up to you. To set this number, put a line in your shell setup file () like this:

set history=40 C shell HISTSIZE=40 bash, ksh

This means that the C shell will save the last 40 commands. To list out these 40 commands use:

% history

To see just the last ten commands in csh or bash, use history 10. In the C shell, you can also list out the commands in reverse with history -r.

To use the ! in a command line, you have several choices. Some of the following examples are more of a headache than they may be worth. But they are used mostly to select arguments from the command line in aliases (). Here they are:

- DR