I was going to write a blog about this, then I came across a Red Hat blog that has all this laid out nice. No point re-inventing the wheel. A while back, I was on the phone with a vendor at work, and the admin controlling the system I was facilitating access to typed !105
and I was like… OK, what just happened, then I realised that '!'
has all sorts of cool functionality in regards to bash history. When you review your bash history by typing 'history'
, you will notice each entry in your command history has a line number. To repeat a command from your history, you just type !<line #>
and the command is repeated. I now use this all the time, especially for complex commands that take some work to get perfect, just bang#
it and you’re good. Somehow it’s quite satisfying. Check out the other cool things you can do with !
in man history
or by checking out the Red Hat blog above.
-Jesse