Linux Quick Tip: History |grep to remember commands

Here is a quick tip for Linux. I use this all the time. If you are trying to remember a command you once did but cant remember the syntax use the following:

history |grep keyword

So if I do history |grep chmod it will tell me all of the commands that I have typed in that contain the word chmod.

matt@ubuntu:~$ history |grep chmod
   70  chmod a+x vlc
  325  chmod a+x downgrade.sh
  326  sudo chmod a+x downgrade.sh
  505  history |grep chmod

You can pipe a lot of things through grep. cat filename |grep keyword can be handy too. This will give you all the lines in filename that have the word keyword in them.

Leave a Reply