Modifying the previous command
A sampling of word substitutions
A sampling of word substitutions
Because word substitution syntax provides so many choices, typical users find it faster to just retype an entire command,
rather than trying to remember the correct syntax. But the simplest word substitutions, listed below, are worth remembering:
| Substitution | What it substitutes |
| !$ | Last argument of previous command |
| !^ | First argument of previous command |
| !* | All arguments of previous command |
Hee are some examples.
They assume that you have just entered this command, which displays the contents of four files named w, x, y, and z:
% cat w x y z
If you used word substitution in the next command, heres what would happen:
| Next command after cat w x y z | Actual command produced |
| % ls l !$ | % ls l z |
| % ls l !^ | % ls l w |
| % ls l !* | % ls l w x y z |