LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices

Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

Ignoring lines starting with space, and other patterns in bash_history

Posted 08-25-2013 at 11:18 PM by the dsc
Updated 08-25-2013 at 11:22 PM by the dsc

It may be a little bit unsafe to have "rm something" commands in your bash history, if you also have the history easily accessible through up and down keys.

The following line will make bash history ignore "rm" and "shutdown":

Code:
export HISTIGNORE="&:rm *:shutdown *"
I don't know the syntax, but it works.

Some people have add there an expression to make bash's history ignore any line starting with a space, it would be ":[\t]*" at the end of that string, but I've found that it was also making the history ignore anything starting with "t" (perhaps because I had missed the space between "[" abd "\", like I just did). There's a better way to do it:

Quote:
Originally Posted by Hnat Kubov
I know this post is too old, but since it shows up in google search on "histignore", I have to add, that there's more-- em, 'built-in' way of ignoring commands that start with " ". So, instead of adding "[ \t]*" to HISTIGNORE, you can use HISTCONTROL=ignorespace. But actually I don't know if it makes any difference. Just makes your .bashrc more readable.

http://www.techrepublic.com/article/...gnore-in-bash/
"HISTCONTROL=ignoreboth" will ignore both lines starting with spaces, and duplicate lines.
Posted in Uncategorized
Views 410 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 09:48 AM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration