Many Linux users usually need to repeat the same command over and over again. For the newbie she will often re-write the whole command. The average use might already know that there’s something called a bash history and so she would use the up and down arrows to navigate through the history. It will take a while to find the needed command.
The more advanced user would know the trick I am about to tell you to find the appropriate command in less than 3 seconds.
This is done with something called “reverse-i-search”.
The trick is simple:
- Ctrl+R
- start typing any part of the command
- Press the return key.
The Ctrl+R will display the following in the terminal:
You will see the history displaying previously run commands until you get an exact match of the one you are typing. This takes less than a 3 seconds if you know which key letters to use.
For example, everyday I issue a command to suspend my laptop at 0645. to do this I need to run the following command:
echo pm-suspend | sudo at -t MMDDhhmm
where ” MMDDhhmm ” represents the month, day of the month followed by the hour and minute the command should suspend the computer. In the image below this is 06060645 representing month 6, day 6 of this month and at 6 o’clock and 45 minutes in the morning. Note that to suspend at night you need to use the 24-hour format (e.g; 2345 for 1145)
Instead of having to write the whole line, I use the above trick along and just type the first three letters of suspend:
For this command all I have to edit is the day of the month (i.e; 06) to the day of interest. It depends on the command you use and what you want to do, you may need to edit a few characters, several, or none.
If you enjoyed this post or found it useful please consider sharing it using the buttons below and supporting the blog using flattr or some bitcoins:
1BgwrNmtgWSth7KC67MZEbBhnsPshSb4x