Here is the video version, if you prefer it:
Let’s say you want to search for a particular command in your command line history. You could write history | grep pattern
, but there is a better way. Reverse incremental search to the rescue!
Here is how to use reverse incremental search: (Shotts, 2019)
When in a Terminal window, press ^ + R
(CTRL + R
) to initiate it. Start typing in the command you are looking for in history. As you type in more characters of the command, the search will refine itself. If you want to execute the command currently displayed, press ENTER. If you want to copy the command to your current terminal session, press ^ + J
(CTRL + J
).
It should look something like this:
(reverse-i-search)`sudo': history | grep sudo
This is something I rarely use (I use the Up/Down arrows), but something that I have in the back of my head should I need it. I have also seen this being used by other Linux users in their day-to-day, so I thought that this was important to cover.
Hope you learned something useful!
References
Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 110-112
Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.