익명 16:32

Using HISTIGNORE in Bash

Using HISTIGNORE in Bash

I was reading the man pages for Bash on the plane and I stumbled across the HISTIGNORE variable. To test it out, I immediately edited my .profile file to define this variable:

export HISTIGNORE=ls

I tested it out and this is great! It excludes plain 'ls' commands from my history without excluding more interesting commands with lengthy paths, but having recently harvested a great deal of wisdom from Super User I am eager to know what other commands superusers might recommend or other lessons learned.

How can I use the HISTIGNORE variable in Bash?



Top Answer/Comment:

I ignore ls without commands, bg, fg, exit, pwd, clear, mount and umount:

If you include this in your HISTIGNORE string you can suppress anything as you wish by adding a space at the front of the command:

"[ \t]*" 

This is my HISTIGNORE:

HISTIGNORE="&:ls:[bf]g:exit:pwd:clear:mount:umount:[ \t]*"

I've excluded some other stuff that I have in there that are repetitive commands that are unique to my server. Anything you do that is simple is a good thing to exclude.

I have other stuff which I have forgotten to add but I'm miles away from my Linux box so I am going off of memory.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다