While googling for something completely different (which I cannot remember right now), I passed by what is probably the best Bash tip I ever read:
bash$ head -10 /etc/apache2/sites-available/default (...) bash$ ^10^20^ (...) |
What happens in the second command is that the previous one is repeated, replacing “10” by “20”! How great is that?!










See this: http://successtheory.com/tips/zshtips.html
http://samrowe.com/wordpress/advancing-in-the-bash-shell/ has that and more.
Some comments I put at our Developers’ Weblog
Of course, mksh(1) can do it as well:
What’s best, the modified commands are written into the history, not the modificator itself.
Some of the commentaries are rather clueless too, not $! but $_ is the last word of the last command, in this case:
Instead of “^-s” you would use “r — -s=” (the two dashes are needed as the “r” built-in alias parses its arguments).
OLD TIP IS OLD!!
yeah i find that ^old^new really useful.
another tip:
the last line will remove the -s option and thus install zsh
Check out this book, it’s got all the tips you could want:
Bash-Z-Shell-Conquering-Command
You probably know this one, but I’ll share for others who might not:
The $! reuses the last argument of the previous command.