[How to] Search through Bash history – sathyasays.com
This page looks best with JavaScript enabled

[How to] Search through Bash history

 ·   ·  ☕ 1 min read  ·  ✍️ Sathyajith Bhat · 👀... views

Quick tip - if you use the Terminal as much as I do, ever been in a situation where you’ve written a particularly long command, and then want to issue that command again but can’t recall it ? Use the history command, and pipe it to grep to search it!

history | grep -i <search-term>

This will give you all commands with the search term and the corresponding line number.

To reissue that command, type

!history <line-number><br />

Simple, easy & effective. CLI ftw.

Share on

Sathyajith Bhat
WRITTEN BY
Sathyajith Bhat
Author, AWS Container Hero and DevOps Specialist

What's on this Page