Categories
Linux

Control + R in Bash = Life Changed

Searching your Bash history the easy way.

I’m probably late to the party on this one.

I was working with someone the other day on a problem over a video call and sharing my screen on a Linux box.

They watched as I did what I do often and Grep’ed through my command history to find a command I’d run before but couldn’t remember the specifics of off the top of my head.

Something like this:

How I’ve always found commands from my history

Then the person I was working with told me to try pressing Control + R and typing the start of what I was looking for.

My head exploded.

Searching through Bash command history

From here you can search through your command history and scroll between matching entries,

I cannot believe it’s taken me this long to learn!

Want more? 
You can also get the weekly posts on the blog by Connecting on LinkedIn, following me on Twitter, or Subscribing via RSS.

One reply on “Control + R in Bash = Life Changed”

Nice to know! I always modify /etc/inputrc and uncomment the bindings for PgUp/PgDown keys to search through the history, based on what is on the command line and where the cursor is. E.g. If I out “apt in” and press PgUp it will cycle through all the apt install commands I’ve previously entered.

Leave a Reply

Your email address will not be published. Required fields are marked *