Hack 64. Ignore specific commands from the history using HISTIGNORE

by Ramesh

Sometimes you may not want to clutter your history with basic commands such as pwd and ls. Use HISTIGNORE to specify all the commands that you want to ignore from the history.Please note that adding ls to the HISTIGNORE ignores only ls and not ls -l. So, you have to provide the exact command that you would like to ignore from the history.

  1. # export HISTIGNORE=”pwd:ls:ls –ltr:”
  2.  
  3. # pwd
  4.  
  5. # ls
  6.  
  7. # ls -ltr
  8.  
  9. # service httpd stop
  10.  
  11. # history | tail -3
  12. 79 export HISTIGNORE=”pwd:ls:ls -ltr:”
  13. 80 service httpd stop
  14. 81 history
  15.  
  16. [Note: History did not display pwd and ls]