Bash Shortcut to Repeat Last Command
Gnu's Bash is without a doubt the most common shell among Linux distributions and is also very common in other Unices. One great thing about Bash is that there are many shortcuts and such that make using the terminal a more pleasent experience. One of my personal favorites is !! to repeat the last used command.
!! is an easy shortcut that repeats the last used command. If you enter it on the command line by itself, it is the equivalent of pressing up+enter. However, using !! allows you to quickly add things to the command you just entered by adding them before or after the !! depending on your situation. Let's look at a few examples.
- You forget to run a command, such as to install a package, as root. sudo !!1
- You forget to specify a file name when opening a text file. !! file.xml
- There is too much text to read when you display some sort of text. !! | more
- You want to rerun a command with a(n) argument(s). !! -a

There are many more situations where this quick shortcut can be useful. It is amazing how even the most simple things can be the best productivity boosters. Also, don't forget to try using Bash keyboard shortcuts as well.
1This idea is from the main How-To Geek site.


b05db3bdc931…
b05db3bdc931ed21dbff…