Another nice ending is `:p` to print the command instead of executing it. I use this if I'm doing something complicated and I want to make sure it's right. Or if I'm saying `!-n:foo` with n>2. Then just up-arrow and enter to run it for real.
$ echo a b c d
a b c d
$ echo !!:2:p
echo b
$ echo !!:2
-bash: :2: bad word specifier # there was only 1 argument in last command
However: $ echo a b c d
a b c d
$ echo !!:2:p
echo b
$
<up-arrow pressed once will give the following prompt>
$ echo b $if Bash
Space: magic-space
$endif
Basically does the same thing as :p, but after a space instead of enter.Edit: fixed formatting.
shopt -s histverify
to show the expanded command before executing it. Then just enter. I never get these right the first time.