Tips & How-To's

[How to] Search through Bash history

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>

Simple, easy & effective. CLI ftw.


Leave a Reply to Sathya Cancel reply

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