Keep all commands in bash history?












4














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.



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?
    – Didi 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?
    – Didi 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
















4














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.



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?
    – Didi 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?
    – Didi 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














4












4








4


2





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.



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



set pastie










share|improve this question















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.



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



set pastie







bash command-history






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Rui F Ribeiro

38.8k1479128




38.8k1479128










asked Dec 6 '12 at 10:01









Prof. Falken

12316




12316








  • 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?
    – Didi 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?
    – Didi 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














  • 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?
    – Didi 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?
    – Didi 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








3




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?
– Didi Kohen
Dec 6 '12 at 10:25




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?
– Didi Kohen
Dec 6 '12 at 10:25












@DavidKohen, added pastebin link.
– Prof. Falken
Dec 6 '12 at 10:43




@DavidKohen, added pastebin link.
– Prof. Falken
Dec 6 '12 at 10:43




1




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?
– Didi Kohen
Dec 6 '12 at 10:55






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?
– Didi 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




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




The 'this' and 'much prefer this' lead to the same place, which is a bit confusing...
– goldilocks
Dec 6 '12 at 12:27










3 Answers
3






active

oldest

votes


















3














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





























    4














    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





























      0














      FWIW, I use HISTFILE=~/.bash_history_$(date '+%Y%m%d_%H_%M_%S_%N').txt in my .bashrc file to make a single history file for each session, with a timestamp. That way I don't lose commands when I hit $HISTSIZE commands. history only shows me the command history for the current terminal session, but I can easily search previous bash history with grep 'what to find' .bash_history*






      share|improve this answer





















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "106"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f57724%2fkeep-all-commands-in-bash-history%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        3














        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


























          3














          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
























            3












            3








            3






            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 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












            share|improve this answer



            share|improve this answer










            answered Sep 1 '14 at 10:41









            Graham Nicholls

            19412




            19412

























                4














                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


























                  4














                  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
























                    4












                    4








                    4






                    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












                    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












                    share|improve this answer



                    share|improve this answer










                    answered Dec 6 '12 at 12:51









                    goldilocks

                    61.4k13151207




                    61.4k13151207























                        0














                        FWIW, I use HISTFILE=~/.bash_history_$(date '+%Y%m%d_%H_%M_%S_%N').txt in my .bashrc file to make a single history file for each session, with a timestamp. That way I don't lose commands when I hit $HISTSIZE commands. history only shows me the command history for the current terminal session, but I can easily search previous bash history with grep 'what to find' .bash_history*






                        share|improve this answer


























                          0














                          FWIW, I use HISTFILE=~/.bash_history_$(date '+%Y%m%d_%H_%M_%S_%N').txt in my .bashrc file to make a single history file for each session, with a timestamp. That way I don't lose commands when I hit $HISTSIZE commands. history only shows me the command history for the current terminal session, but I can easily search previous bash history with grep 'what to find' .bash_history*






                          share|improve this answer
























                            0












                            0








                            0






                            FWIW, I use HISTFILE=~/.bash_history_$(date '+%Y%m%d_%H_%M_%S_%N').txt in my .bashrc file to make a single history file for each session, with a timestamp. That way I don't lose commands when I hit $HISTSIZE commands. history only shows me the command history for the current terminal session, but I can easily search previous bash history with grep 'what to find' .bash_history*






                            share|improve this answer












                            FWIW, I use HISTFILE=~/.bash_history_$(date '+%Y%m%d_%H_%M_%S_%N').txt in my .bashrc file to make a single history file for each session, with a timestamp. That way I don't lose commands when I hit $HISTSIZE commands. history only shows me the command history for the current terminal session, but I can easily search previous bash history with grep 'what to find' .bash_history*







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered yesterday









                            user208145

                            1,22121215




                            1,22121215






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f57724%2fkeep-all-commands-in-bash-history%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                サソリ

                                広島県道265号伴広島線

                                Setup Asymptote in Texstudio