Using !$ for Safety with Wildcards

We all know about using ls before a wildcarded rm to make sure that we're only deleting what we want. But that doesn't really solve the problem: you can type ls a* and then mistakenly type rm s* with bad consequences - it's just a minor slip of your finger. But what will always work, if you're a csh or bash user, is:

% ls a* a1 a2 a3 % rm !$

(ls -d a* () will make less output if any subdirectory names match the wildcard.)

Using the history mechanism to grab the previous command's arguments is a good way to prevent mistakes.

- ML