Why do commands starting with a space, not show up in bash history? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite













This question already has an answer here:



  • Why is bash not storing commands that start with spaces?

    1 answer



In bash, when I use Ctrl-R to retrieve a previous command, why does it not work when the command starts with a whitespace? Can I make it match such a previous command?



$ date
Fri Nov 23 ... 2018
(failed reverse-i-search)` date': cd database/









share|improve this question















marked as duplicate by muru, andcoz, Christopher, JigglyNaga, Jeff Schaller Nov 23 at 15:49


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    0
    down vote

    favorite













    This question already has an answer here:



    • Why is bash not storing commands that start with spaces?

      1 answer



    In bash, when I use Ctrl-R to retrieve a previous command, why does it not work when the command starts with a whitespace? Can I make it match such a previous command?



    $ date
    Fri Nov 23 ... 2018
    (failed reverse-i-search)` date': cd database/









    share|improve this question















    marked as duplicate by muru, andcoz, Christopher, JigglyNaga, Jeff Schaller Nov 23 at 15:49


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      This question already has an answer here:



      • Why is bash not storing commands that start with spaces?

        1 answer



      In bash, when I use Ctrl-R to retrieve a previous command, why does it not work when the command starts with a whitespace? Can I make it match such a previous command?



      $ date
      Fri Nov 23 ... 2018
      (failed reverse-i-search)` date': cd database/









      share|improve this question
















      This question already has an answer here:



      • Why is bash not storing commands that start with spaces?

        1 answer



      In bash, when I use Ctrl-R to retrieve a previous command, why does it not work when the command starts with a whitespace? Can I make it match such a previous command?



      $ date
      Fri Nov 23 ... 2018
      (failed reverse-i-search)` date': cd database/




      This question already has an answer here:



      • Why is bash not storing commands that start with spaces?

        1 answer







      bash






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 at 15:11









      ctrl-alt-delor

      10.2k41955




      10.2k41955










      asked Nov 23 at 15:06









      Ben

      2769




      2769




      marked as duplicate by muru, andcoz, Christopher, JigglyNaga, Jeff Schaller Nov 23 at 15:49


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by muru, andcoz, Christopher, JigglyNaga, Jeff Schaller Nov 23 at 15:49


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          Check the value of your HISTCONTROL environment variable. If the value contains ignorespace or ignoreboth, any command starting with a space will not be added to command history.



          From man bash:




          HISTCONTROL:
          A colon-separated list of values controlling how commands are saved on the history list. If the list of
          values includes ignorespace, lines which begin with a space character are not saved in the history list.
          A value of ignoredups causes lines matching the previous history entry to not be saved. A value of
          ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines
          matching the current line to be removed from the history list before that line is saved. Any value not
          in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines
          read by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second
          and subsequent lines of a multi-line compound command are not tested, and are added to the history
          regardless of the value of HISTCONTROL.







          share|improve this answer





























            up vote
            1
            down vote













            That is intended. White space makes no change to the interpretation of the command. History ignores command starting with a space, so that you can enter commands that you don't want logged. Now very secure, as someone on same machine, can spy when you do it.



            I think it can be re-configured. See the bash-manual, under history.






            share|improve this answer



























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              4
              down vote



              accepted










              Check the value of your HISTCONTROL environment variable. If the value contains ignorespace or ignoreboth, any command starting with a space will not be added to command history.



              From man bash:




              HISTCONTROL:
              A colon-separated list of values controlling how commands are saved on the history list. If the list of
              values includes ignorespace, lines which begin with a space character are not saved in the history list.
              A value of ignoredups causes lines matching the previous history entry to not be saved. A value of
              ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines
              matching the current line to be removed from the history list before that line is saved. Any value not
              in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines
              read by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second
              and subsequent lines of a multi-line compound command are not tested, and are added to the history
              regardless of the value of HISTCONTROL.







              share|improve this answer


























                up vote
                4
                down vote



                accepted










                Check the value of your HISTCONTROL environment variable. If the value contains ignorespace or ignoreboth, any command starting with a space will not be added to command history.



                From man bash:




                HISTCONTROL:
                A colon-separated list of values controlling how commands are saved on the history list. If the list of
                values includes ignorespace, lines which begin with a space character are not saved in the history list.
                A value of ignoredups causes lines matching the previous history entry to not be saved. A value of
                ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines
                matching the current line to be removed from the history list before that line is saved. Any value not
                in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines
                read by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second
                and subsequent lines of a multi-line compound command are not tested, and are added to the history
                regardless of the value of HISTCONTROL.







                share|improve this answer
























                  up vote
                  4
                  down vote



                  accepted







                  up vote
                  4
                  down vote



                  accepted






                  Check the value of your HISTCONTROL environment variable. If the value contains ignorespace or ignoreboth, any command starting with a space will not be added to command history.



                  From man bash:




                  HISTCONTROL:
                  A colon-separated list of values controlling how commands are saved on the history list. If the list of
                  values includes ignorespace, lines which begin with a space character are not saved in the history list.
                  A value of ignoredups causes lines matching the previous history entry to not be saved. A value of
                  ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines
                  matching the current line to be removed from the history list before that line is saved. Any value not
                  in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines
                  read by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second
                  and subsequent lines of a multi-line compound command are not tested, and are added to the history
                  regardless of the value of HISTCONTROL.







                  share|improve this answer














                  Check the value of your HISTCONTROL environment variable. If the value contains ignorespace or ignoreboth, any command starting with a space will not be added to command history.



                  From man bash:




                  HISTCONTROL:
                  A colon-separated list of values controlling how commands are saved on the history list. If the list of
                  values includes ignorespace, lines which begin with a space character are not saved in the history list.
                  A value of ignoredups causes lines matching the previous history entry to not be saved. A value of
                  ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines
                  matching the current line to be removed from the history list before that line is saved. Any value not
                  in the above list is ignored. If HISTCONTROL is unset, or does not include a valid value, all lines
                  read by the shell parser are saved on the history list, subject to the value of HISTIGNORE. The second
                  and subsequent lines of a multi-line compound command are not tested, and are added to the history
                  regardless of the value of HISTCONTROL.








                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 23 at 17:54









                  Cyrus

                  7,1812835




                  7,1812835










                  answered Nov 23 at 15:16









                  andcoz

                  12.3k33039




                  12.3k33039






















                      up vote
                      1
                      down vote













                      That is intended. White space makes no change to the interpretation of the command. History ignores command starting with a space, so that you can enter commands that you don't want logged. Now very secure, as someone on same machine, can spy when you do it.



                      I think it can be re-configured. See the bash-manual, under history.






                      share|improve this answer
























                        up vote
                        1
                        down vote













                        That is intended. White space makes no change to the interpretation of the command. History ignores command starting with a space, so that you can enter commands that you don't want logged. Now very secure, as someone on same machine, can spy when you do it.



                        I think it can be re-configured. See the bash-manual, under history.






                        share|improve this answer






















                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          That is intended. White space makes no change to the interpretation of the command. History ignores command starting with a space, so that you can enter commands that you don't want logged. Now very secure, as someone on same machine, can spy when you do it.



                          I think it can be re-configured. See the bash-manual, under history.






                          share|improve this answer












                          That is intended. White space makes no change to the interpretation of the command. History ignores command starting with a space, so that you can enter commands that you don't want logged. Now very secure, as someone on same machine, can spy when you do it.



                          I think it can be re-configured. See the bash-manual, under history.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 23 at 15:11









                          ctrl-alt-delor

                          10.2k41955




                          10.2k41955












                              Popular posts from this blog

                              Peggy Mitchell

                              The Forum (Inglewood, California)

                              Palaiologos