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:
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.
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!
You can also get the weekly posts on the blog by Connecting on LinkedIn, following me on Twitter, or Subscribing via RSS.
2 replies 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.
I was just looking at how to store history across multiple screens and sessions. This fits in nicely, I had not seen it before