Search History in Bash

Search History in Bash

I keep using history | grep but is there a better way of searching history?
Digital Ocean has a nice blog post on history in bash

CTRL-R quickly search the history. eg CTRL-R ssh

!-2 will run the 2nd last command entered into history.
!! runs the previous command which can be combined with sudo sudo !!
!1 will get the 1st (or nth if you change 1) argument of the previous command.

Leave a Reply

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