How can I recall a numbered history command for edit?

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












16















I frequently search for changes with history | grep 'string'



I get a list of commands in my history, along with the history line number), e.g.



history | grep 'git'

755 git status
1535 git push origin master
1570 git merge origin/one-146
1667 git reset --hard origin/master


I can now recall and execute a command in one go with !nnn, for example:



!755
git status
# On branch master
nothing to commit, working directory clean


My question is: How can I recall a numbered history command and stay on the commands line for editing and not execute it right away 'as is', the way that ! does, so that I can change a couple of things peform presing return?










share|improve this question




























    16















    I frequently search for changes with history | grep 'string'



    I get a list of commands in my history, along with the history line number), e.g.



    history | grep 'git'

    755 git status
    1535 git push origin master
    1570 git merge origin/one-146
    1667 git reset --hard origin/master


    I can now recall and execute a command in one go with !nnn, for example:



    !755
    git status
    # On branch master
    nothing to commit, working directory clean


    My question is: How can I recall a numbered history command and stay on the commands line for editing and not execute it right away 'as is', the way that ! does, so that I can change a couple of things peform presing return?










    share|improve this question


























      16












      16








      16


      8






      I frequently search for changes with history | grep 'string'



      I get a list of commands in my history, along with the history line number), e.g.



      history | grep 'git'

      755 git status
      1535 git push origin master
      1570 git merge origin/one-146
      1667 git reset --hard origin/master


      I can now recall and execute a command in one go with !nnn, for example:



      !755
      git status
      # On branch master
      nothing to commit, working directory clean


      My question is: How can I recall a numbered history command and stay on the commands line for editing and not execute it right away 'as is', the way that ! does, so that I can change a couple of things peform presing return?










      share|improve this question
















      I frequently search for changes with history | grep 'string'



      I get a list of commands in my history, along with the history line number), e.g.



      history | grep 'git'

      755 git status
      1535 git push origin master
      1570 git merge origin/one-146
      1667 git reset --hard origin/master


      I can now recall and execute a command in one go with !nnn, for example:



      !755
      git status
      # On branch master
      nothing to commit, working directory clean


      My question is: How can I recall a numbered history command and stay on the commands line for editing and not execute it right away 'as is', the way that ! does, so that I can change a couple of things peform presing return?







      bash command-history






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 8 '13 at 18:44







      Michael Durrant

















      asked Dec 8 '13 at 18:30









      Michael DurrantMichael Durrant

      16k44117183




      16k44117183




















          5 Answers
          5






          active

          oldest

          votes


















          11














          I've since adopted another approach to this - using ![line-number]:p



          This prints the statement and adds it to history but doesn't actually execute it. I then do up arrow and change it as desired.



          I combine this with my hg alias (alias hg='history | grep ') to recall history commands based on some text.



          Example:



          $ hg checkout

          17140 git checkout README.rdoc
          17143 git checkout master
          17201 git checkout README.rdoc
          17204 git checkout master
          17923 git checkout .bashrc
          18151 git checkout v311


          I use this in addition to ctrl-r (reverse history search) because sometimes I prefer to see an immediate list of all the possibilities for a given string rather than just the output on 1 line that ctrl-r shows. After hg [string] I would then do ![line-number]search_string as in the hg checkout shown above.






          share|improve this answer






























            8














            If you set the histverify option, e.g.



            shopt -s histverify


            then all history substitutions are brought up for editing instead of being executed immediately. You would then need to press Enter twice instead of once after typing !755 to execute the command.



            You can push arbitrary text onto the history list with history -s. Combine this with fc -nl to list a specific history entry.



            history -s "$(fc -nl 755 755)"


            then press Up to recall what is now the latest history entry.






            share|improve this answer
































              6














              You can search back through the history using Ctrl+R. If the history entry is long use the mouse (not the keyboard, that stops the search) to copy and paste part of the command to edit back in.



              As @rijsg commented, you can then use the (left and right) arrows or equivalent keys to stop the search and start editing.






              share|improve this answer




















              • 2





                Any arrow key or equivalent command (Ctrl-a for example) will stop the search leaving the current history entry in the command prompt, without executing it. This may or may not be enough, depending on what @Michael wants.

                – njsg
                Dec 8 '13 at 19:03











              • @rijsg Thanks for the expansion, you are right.

                – Zelda
                Dec 8 '13 at 19:29


















              2














              If you configure your .bashrc file to use the vi editor
              at the command line it will make command line edits so much less complex.



              1st, once "set -o vi" is enabled, you can simply hit "<esc> k",
              then keep hitting "k" to go up the history file as it were,
              if you go past an entry, use "j" to go down.



              NOTE: when using vi, there are two modes: command and edit
              to enter the command mode hit the ESCAPE KEY ONCE,
              then a,A,i,I, etc. to insert.



              Simple cursor pad in vi: left=h, down=j, up=k, right=l
              http://linuxmeister.net/vi/vi-Summary.jpg



              I've added all the entries needed to make this work at:
              http://linuxmeister.net/Notes/bashrc-simple.html



              So, based on the very helpful information above,
              I was able to use "history" and RECALL a line from "history", WITHOUT executing it. (THANK YOU FOR THAT POST!)



              if shopt is listed and
              histverify is "off" a ! will EXECUTE immediately,



              if you've added to your .bashrc, or typed: shopt -s histverify,
              then a ! allows an edit, for example:



              history
              1 more .bashrc
              2 history
              3 shopt
              4 . ./.bashrc
              5 shopt | grep hist
              6 history
              7 alias
              8 history
              9 shopt
              10 history



              --> !5



              when I hit !5 the following command appears, but does NOT execute



              ### if histverify is "on".



              shopt | grep hist
              cmdhist on
              histappend on
              histreedit off
              histverify on
              lithist off



              Remember that Linus and Richard created Linux and GNU tools
              to take advantage of UNIX. The vi editor (created by Bill Joy)
              is one of the best tools to master as it is on EVERY distribution of UNIX
              and Linux.



              All of the other command line editors need to be loaded and
              require additional software. Using a GUI in Linux
              (other than Firefox, Thunderbird, and OpenOffice)
              is like towing your Diesel 4x4 with a 1968 VW Beetle...
              it'll work, but it sure doesn't make any sense.



              Remember what Kernigan said about a GUI, "what you see is all you get".






              share|improve this answer
































                -1














                echo !number


                then hit up-arrow, remove the word echo and edit the rest; press enter to execute.






                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%2f104257%2fhow-can-i-recall-a-numbered-history-command-for-edit%23new-answer', 'question_page');

                  );

                  Post as a guest















                  Required, but never shown

























                  5 Answers
                  5






                  active

                  oldest

                  votes








                  5 Answers
                  5






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  11














                  I've since adopted another approach to this - using ![line-number]:p



                  This prints the statement and adds it to history but doesn't actually execute it. I then do up arrow and change it as desired.



                  I combine this with my hg alias (alias hg='history | grep ') to recall history commands based on some text.



                  Example:



                  $ hg checkout

                  17140 git checkout README.rdoc
                  17143 git checkout master
                  17201 git checkout README.rdoc
                  17204 git checkout master
                  17923 git checkout .bashrc
                  18151 git checkout v311


                  I use this in addition to ctrl-r (reverse history search) because sometimes I prefer to see an immediate list of all the possibilities for a given string rather than just the output on 1 line that ctrl-r shows. After hg [string] I would then do ![line-number]search_string as in the hg checkout shown above.






                  share|improve this answer



























                    11














                    I've since adopted another approach to this - using ![line-number]:p



                    This prints the statement and adds it to history but doesn't actually execute it. I then do up arrow and change it as desired.



                    I combine this with my hg alias (alias hg='history | grep ') to recall history commands based on some text.



                    Example:



                    $ hg checkout

                    17140 git checkout README.rdoc
                    17143 git checkout master
                    17201 git checkout README.rdoc
                    17204 git checkout master
                    17923 git checkout .bashrc
                    18151 git checkout v311


                    I use this in addition to ctrl-r (reverse history search) because sometimes I prefer to see an immediate list of all the possibilities for a given string rather than just the output on 1 line that ctrl-r shows. After hg [string] I would then do ![line-number]search_string as in the hg checkout shown above.






                    share|improve this answer

























                      11












                      11








                      11







                      I've since adopted another approach to this - using ![line-number]:p



                      This prints the statement and adds it to history but doesn't actually execute it. I then do up arrow and change it as desired.



                      I combine this with my hg alias (alias hg='history | grep ') to recall history commands based on some text.



                      Example:



                      $ hg checkout

                      17140 git checkout README.rdoc
                      17143 git checkout master
                      17201 git checkout README.rdoc
                      17204 git checkout master
                      17923 git checkout .bashrc
                      18151 git checkout v311


                      I use this in addition to ctrl-r (reverse history search) because sometimes I prefer to see an immediate list of all the possibilities for a given string rather than just the output on 1 line that ctrl-r shows. After hg [string] I would then do ![line-number]search_string as in the hg checkout shown above.






                      share|improve this answer













                      I've since adopted another approach to this - using ![line-number]:p



                      This prints the statement and adds it to history but doesn't actually execute it. I then do up arrow and change it as desired.



                      I combine this with my hg alias (alias hg='history | grep ') to recall history commands based on some text.



                      Example:



                      $ hg checkout

                      17140 git checkout README.rdoc
                      17143 git checkout master
                      17201 git checkout README.rdoc
                      17204 git checkout master
                      17923 git checkout .bashrc
                      18151 git checkout v311


                      I use this in addition to ctrl-r (reverse history search) because sometimes I prefer to see an immediate list of all the possibilities for a given string rather than just the output on 1 line that ctrl-r shows. After hg [string] I would then do ![line-number]search_string as in the hg checkout shown above.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered May 15 '14 at 22:09









                      Michael DurrantMichael Durrant

                      16k44117183




                      16k44117183























                          8














                          If you set the histverify option, e.g.



                          shopt -s histverify


                          then all history substitutions are brought up for editing instead of being executed immediately. You would then need to press Enter twice instead of once after typing !755 to execute the command.



                          You can push arbitrary text onto the history list with history -s. Combine this with fc -nl to list a specific history entry.



                          history -s "$(fc -nl 755 755)"


                          then press Up to recall what is now the latest history entry.






                          share|improve this answer





























                            8














                            If you set the histverify option, e.g.



                            shopt -s histverify


                            then all history substitutions are brought up for editing instead of being executed immediately. You would then need to press Enter twice instead of once after typing !755 to execute the command.



                            You can push arbitrary text onto the history list with history -s. Combine this with fc -nl to list a specific history entry.



                            history -s "$(fc -nl 755 755)"


                            then press Up to recall what is now the latest history entry.






                            share|improve this answer



























                              8












                              8








                              8







                              If you set the histverify option, e.g.



                              shopt -s histverify


                              then all history substitutions are brought up for editing instead of being executed immediately. You would then need to press Enter twice instead of once after typing !755 to execute the command.



                              You can push arbitrary text onto the history list with history -s. Combine this with fc -nl to list a specific history entry.



                              history -s "$(fc -nl 755 755)"


                              then press Up to recall what is now the latest history entry.






                              share|improve this answer















                              If you set the histverify option, e.g.



                              shopt -s histverify


                              then all history substitutions are brought up for editing instead of being executed immediately. You would then need to press Enter twice instead of once after typing !755 to execute the command.



                              You can push arbitrary text onto the history list with history -s. Combine this with fc -nl to list a specific history entry.



                              history -s "$(fc -nl 755 755)"


                              then press Up to recall what is now the latest history entry.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Dec 10 '13 at 14:15









                              Michael Durrant

                              16k44117183




                              16k44117183










                              answered Dec 8 '13 at 23:31









                              GillesGilles

                              534k12810801597




                              534k12810801597





















                                  6














                                  You can search back through the history using Ctrl+R. If the history entry is long use the mouse (not the keyboard, that stops the search) to copy and paste part of the command to edit back in.



                                  As @rijsg commented, you can then use the (left and right) arrows or equivalent keys to stop the search and start editing.






                                  share|improve this answer




















                                  • 2





                                    Any arrow key or equivalent command (Ctrl-a for example) will stop the search leaving the current history entry in the command prompt, without executing it. This may or may not be enough, depending on what @Michael wants.

                                    – njsg
                                    Dec 8 '13 at 19:03











                                  • @rijsg Thanks for the expansion, you are right.

                                    – Zelda
                                    Dec 8 '13 at 19:29















                                  6














                                  You can search back through the history using Ctrl+R. If the history entry is long use the mouse (not the keyboard, that stops the search) to copy and paste part of the command to edit back in.



                                  As @rijsg commented, you can then use the (left and right) arrows or equivalent keys to stop the search and start editing.






                                  share|improve this answer




















                                  • 2





                                    Any arrow key or equivalent command (Ctrl-a for example) will stop the search leaving the current history entry in the command prompt, without executing it. This may or may not be enough, depending on what @Michael wants.

                                    – njsg
                                    Dec 8 '13 at 19:03











                                  • @rijsg Thanks for the expansion, you are right.

                                    – Zelda
                                    Dec 8 '13 at 19:29













                                  6












                                  6








                                  6







                                  You can search back through the history using Ctrl+R. If the history entry is long use the mouse (not the keyboard, that stops the search) to copy and paste part of the command to edit back in.



                                  As @rijsg commented, you can then use the (left and right) arrows or equivalent keys to stop the search and start editing.






                                  share|improve this answer















                                  You can search back through the history using Ctrl+R. If the history entry is long use the mouse (not the keyboard, that stops the search) to copy and paste part of the command to edit back in.



                                  As @rijsg commented, you can then use the (left and right) arrows or equivalent keys to stop the search and start editing.







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Dec 8 '13 at 19:30

























                                  answered Dec 8 '13 at 18:35









                                  ZeldaZelda

                                  4,7921526




                                  4,7921526







                                  • 2





                                    Any arrow key or equivalent command (Ctrl-a for example) will stop the search leaving the current history entry in the command prompt, without executing it. This may or may not be enough, depending on what @Michael wants.

                                    – njsg
                                    Dec 8 '13 at 19:03











                                  • @rijsg Thanks for the expansion, you are right.

                                    – Zelda
                                    Dec 8 '13 at 19:29












                                  • 2





                                    Any arrow key or equivalent command (Ctrl-a for example) will stop the search leaving the current history entry in the command prompt, without executing it. This may or may not be enough, depending on what @Michael wants.

                                    – njsg
                                    Dec 8 '13 at 19:03











                                  • @rijsg Thanks for the expansion, you are right.

                                    – Zelda
                                    Dec 8 '13 at 19:29







                                  2




                                  2





                                  Any arrow key or equivalent command (Ctrl-a for example) will stop the search leaving the current history entry in the command prompt, without executing it. This may or may not be enough, depending on what @Michael wants.

                                  – njsg
                                  Dec 8 '13 at 19:03





                                  Any arrow key or equivalent command (Ctrl-a for example) will stop the search leaving the current history entry in the command prompt, without executing it. This may or may not be enough, depending on what @Michael wants.

                                  – njsg
                                  Dec 8 '13 at 19:03













                                  @rijsg Thanks for the expansion, you are right.

                                  – Zelda
                                  Dec 8 '13 at 19:29





                                  @rijsg Thanks for the expansion, you are right.

                                  – Zelda
                                  Dec 8 '13 at 19:29











                                  2














                                  If you configure your .bashrc file to use the vi editor
                                  at the command line it will make command line edits so much less complex.



                                  1st, once "set -o vi" is enabled, you can simply hit "<esc> k",
                                  then keep hitting "k" to go up the history file as it were,
                                  if you go past an entry, use "j" to go down.



                                  NOTE: when using vi, there are two modes: command and edit
                                  to enter the command mode hit the ESCAPE KEY ONCE,
                                  then a,A,i,I, etc. to insert.



                                  Simple cursor pad in vi: left=h, down=j, up=k, right=l
                                  http://linuxmeister.net/vi/vi-Summary.jpg



                                  I've added all the entries needed to make this work at:
                                  http://linuxmeister.net/Notes/bashrc-simple.html



                                  So, based on the very helpful information above,
                                  I was able to use "history" and RECALL a line from "history", WITHOUT executing it. (THANK YOU FOR THAT POST!)



                                  if shopt is listed and
                                  histverify is "off" a ! will EXECUTE immediately,



                                  if you've added to your .bashrc, or typed: shopt -s histverify,
                                  then a ! allows an edit, for example:



                                  history
                                  1 more .bashrc
                                  2 history
                                  3 shopt
                                  4 . ./.bashrc
                                  5 shopt | grep hist
                                  6 history
                                  7 alias
                                  8 history
                                  9 shopt
                                  10 history



                                  --> !5



                                  when I hit !5 the following command appears, but does NOT execute



                                  ### if histverify is "on".



                                  shopt | grep hist
                                  cmdhist on
                                  histappend on
                                  histreedit off
                                  histverify on
                                  lithist off



                                  Remember that Linus and Richard created Linux and GNU tools
                                  to take advantage of UNIX. The vi editor (created by Bill Joy)
                                  is one of the best tools to master as it is on EVERY distribution of UNIX
                                  and Linux.



                                  All of the other command line editors need to be loaded and
                                  require additional software. Using a GUI in Linux
                                  (other than Firefox, Thunderbird, and OpenOffice)
                                  is like towing your Diesel 4x4 with a 1968 VW Beetle...
                                  it'll work, but it sure doesn't make any sense.



                                  Remember what Kernigan said about a GUI, "what you see is all you get".






                                  share|improve this answer





























                                    2














                                    If you configure your .bashrc file to use the vi editor
                                    at the command line it will make command line edits so much less complex.



                                    1st, once "set -o vi" is enabled, you can simply hit "<esc> k",
                                    then keep hitting "k" to go up the history file as it were,
                                    if you go past an entry, use "j" to go down.



                                    NOTE: when using vi, there are two modes: command and edit
                                    to enter the command mode hit the ESCAPE KEY ONCE,
                                    then a,A,i,I, etc. to insert.



                                    Simple cursor pad in vi: left=h, down=j, up=k, right=l
                                    http://linuxmeister.net/vi/vi-Summary.jpg



                                    I've added all the entries needed to make this work at:
                                    http://linuxmeister.net/Notes/bashrc-simple.html



                                    So, based on the very helpful information above,
                                    I was able to use "history" and RECALL a line from "history", WITHOUT executing it. (THANK YOU FOR THAT POST!)



                                    if shopt is listed and
                                    histverify is "off" a ! will EXECUTE immediately,



                                    if you've added to your .bashrc, or typed: shopt -s histverify,
                                    then a ! allows an edit, for example:



                                    history
                                    1 more .bashrc
                                    2 history
                                    3 shopt
                                    4 . ./.bashrc
                                    5 shopt | grep hist
                                    6 history
                                    7 alias
                                    8 history
                                    9 shopt
                                    10 history



                                    --> !5



                                    when I hit !5 the following command appears, but does NOT execute



                                    ### if histverify is "on".



                                    shopt | grep hist
                                    cmdhist on
                                    histappend on
                                    histreedit off
                                    histverify on
                                    lithist off



                                    Remember that Linus and Richard created Linux and GNU tools
                                    to take advantage of UNIX. The vi editor (created by Bill Joy)
                                    is one of the best tools to master as it is on EVERY distribution of UNIX
                                    and Linux.



                                    All of the other command line editors need to be loaded and
                                    require additional software. Using a GUI in Linux
                                    (other than Firefox, Thunderbird, and OpenOffice)
                                    is like towing your Diesel 4x4 with a 1968 VW Beetle...
                                    it'll work, but it sure doesn't make any sense.



                                    Remember what Kernigan said about a GUI, "what you see is all you get".






                                    share|improve this answer



























                                      2












                                      2








                                      2







                                      If you configure your .bashrc file to use the vi editor
                                      at the command line it will make command line edits so much less complex.



                                      1st, once "set -o vi" is enabled, you can simply hit "<esc> k",
                                      then keep hitting "k" to go up the history file as it were,
                                      if you go past an entry, use "j" to go down.



                                      NOTE: when using vi, there are two modes: command and edit
                                      to enter the command mode hit the ESCAPE KEY ONCE,
                                      then a,A,i,I, etc. to insert.



                                      Simple cursor pad in vi: left=h, down=j, up=k, right=l
                                      http://linuxmeister.net/vi/vi-Summary.jpg



                                      I've added all the entries needed to make this work at:
                                      http://linuxmeister.net/Notes/bashrc-simple.html



                                      So, based on the very helpful information above,
                                      I was able to use "history" and RECALL a line from "history", WITHOUT executing it. (THANK YOU FOR THAT POST!)



                                      if shopt is listed and
                                      histverify is "off" a ! will EXECUTE immediately,



                                      if you've added to your .bashrc, or typed: shopt -s histverify,
                                      then a ! allows an edit, for example:



                                      history
                                      1 more .bashrc
                                      2 history
                                      3 shopt
                                      4 . ./.bashrc
                                      5 shopt | grep hist
                                      6 history
                                      7 alias
                                      8 history
                                      9 shopt
                                      10 history



                                      --> !5



                                      when I hit !5 the following command appears, but does NOT execute



                                      ### if histverify is "on".



                                      shopt | grep hist
                                      cmdhist on
                                      histappend on
                                      histreedit off
                                      histverify on
                                      lithist off



                                      Remember that Linus and Richard created Linux and GNU tools
                                      to take advantage of UNIX. The vi editor (created by Bill Joy)
                                      is one of the best tools to master as it is on EVERY distribution of UNIX
                                      and Linux.



                                      All of the other command line editors need to be loaded and
                                      require additional software. Using a GUI in Linux
                                      (other than Firefox, Thunderbird, and OpenOffice)
                                      is like towing your Diesel 4x4 with a 1968 VW Beetle...
                                      it'll work, but it sure doesn't make any sense.



                                      Remember what Kernigan said about a GUI, "what you see is all you get".






                                      share|improve this answer















                                      If you configure your .bashrc file to use the vi editor
                                      at the command line it will make command line edits so much less complex.



                                      1st, once "set -o vi" is enabled, you can simply hit "<esc> k",
                                      then keep hitting "k" to go up the history file as it were,
                                      if you go past an entry, use "j" to go down.



                                      NOTE: when using vi, there are two modes: command and edit
                                      to enter the command mode hit the ESCAPE KEY ONCE,
                                      then a,A,i,I, etc. to insert.



                                      Simple cursor pad in vi: left=h, down=j, up=k, right=l
                                      http://linuxmeister.net/vi/vi-Summary.jpg



                                      I've added all the entries needed to make this work at:
                                      http://linuxmeister.net/Notes/bashrc-simple.html



                                      So, based on the very helpful information above,
                                      I was able to use "history" and RECALL a line from "history", WITHOUT executing it. (THANK YOU FOR THAT POST!)



                                      if shopt is listed and
                                      histverify is "off" a ! will EXECUTE immediately,



                                      if you've added to your .bashrc, or typed: shopt -s histverify,
                                      then a ! allows an edit, for example:



                                      history
                                      1 more .bashrc
                                      2 history
                                      3 shopt
                                      4 . ./.bashrc
                                      5 shopt | grep hist
                                      6 history
                                      7 alias
                                      8 history
                                      9 shopt
                                      10 history



                                      --> !5



                                      when I hit !5 the following command appears, but does NOT execute



                                      ### if histverify is "on".



                                      shopt | grep hist
                                      cmdhist on
                                      histappend on
                                      histreedit off
                                      histverify on
                                      lithist off



                                      Remember that Linus and Richard created Linux and GNU tools
                                      to take advantage of UNIX. The vi editor (created by Bill Joy)
                                      is one of the best tools to master as it is on EVERY distribution of UNIX
                                      and Linux.



                                      All of the other command line editors need to be loaded and
                                      require additional software. Using a GUI in Linux
                                      (other than Firefox, Thunderbird, and OpenOffice)
                                      is like towing your Diesel 4x4 with a 1968 VW Beetle...
                                      it'll work, but it sure doesn't make any sense.



                                      Remember what Kernigan said about a GUI, "what you see is all you get".







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Jun 11 '16 at 6:47









                                      jasonwryan

                                      49.8k14134187




                                      49.8k14134187










                                      answered Jun 11 '16 at 4:47









                                      LinuxMeisterLinuxMeister

                                      211




                                      211





















                                          -1














                                          echo !number


                                          then hit up-arrow, remove the word echo and edit the rest; press enter to execute.






                                          share|improve this answer





























                                            -1














                                            echo !number


                                            then hit up-arrow, remove the word echo and edit the rest; press enter to execute.






                                            share|improve this answer



























                                              -1












                                              -1








                                              -1







                                              echo !number


                                              then hit up-arrow, remove the word echo and edit the rest; press enter to execute.






                                              share|improve this answer















                                              echo !number


                                              then hit up-arrow, remove the word echo and edit the rest; press enter to execute.







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Jan 16 at 17:09









                                              Jeff Schaller

                                              40.8k1056129




                                              40.8k1056129










                                              answered Jan 16 at 16:28









                                              AndrzejAndrzej

                                              1




                                              1



























                                                  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.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function ()
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f104257%2fhow-can-i-recall-a-numbered-history-command-for-edit%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

                                                  How to check contact read email or not when send email to Individual?

                                                  Bahrain

                                                  Postfix configuration issue with fips on centos 7; mailgun relay