Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have the opposite question to this. How do I keep all commands in bash history?

In Ubuntu since quite some time now, the default for bash is to forget commands with non success exit code. This is incredibly stupid and I would go with the accepted answer to linked question.

Unix user @goldilocks pointed out that maybe I am just confused by the ignoreboth directive.

set pastie

share|improve this question
3  
To me it looks like this is not the default to forget unsucessful commands in Ubuntu. What version are you using? Could you post a link to the output of the "set" command in pasebin or something so we could see what makes it delete the commands? –  David Kohen Dec 6 '12 at 10:25
    
@DavidKohen, added pastebin link. –  Prof. Falken Dec 6 '12 at 10:43
1  
The only thing I see in relation to history deletion is the fact that it ignores duplicates and lines that start with a space. Are you sure it ignores the failed commands? –  David Kohen Dec 6 '12 at 10:55
    
I was quite sure, but you make me doubt myself. It's not that way for "false". I will come back to this question and update it when annoyance strikes again. –  Prof. Falken Dec 6 '12 at 12:08
    
The 'this' and 'much prefer this' lead to the same place, which is a bit confusing... –  goldilocks Dec 6 '12 at 12:27

2 Answers 2

up vote 2 down vote accepted

I suspect that you're not doing quite what you think you're doing. Run frobiz: , then see if that's in your history. Frobiz should normally fail - there's no such command. But it will be in your history. I suspect that you are trying something like ls *![0-9], which will fail with

ls !(*.[0-9])
base ![0-9]": event not found

The thing is; when failing like this, bash never attempts to run the command, so it doesn't get put into the history. IGNOREBOTH is irrelevant to this - it works as advertised. Try escaping the ! (which the shell is taking to refer, ironically, to a command in the history) - eg:

ls \! ...

And it will probably work as expected.

share|improve this answer

I think you are confused because of HISTCONTROL=ignoreboth. See here: http://www.linuxjournal.com/content/using-bash-history-more-efficiently-histcontrol

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.