How to recall history command for editing - Setup

This is a discussion on How to recall history command for editing - Setup ; I am looking for a way to recall a previous history command for editing, without executing it automatically. The up and down cursor keys are not really useful with a long history. Does the history or shell have any option ...

+ Reply to Thread
Results 1 to 14 of 14

Thread: How to recall history command for editing

  1. How to recall history command for editing


    I am looking for a way to recall a previous history command for
    editing, without executing it automatically.

    The up and down cursor keys are not really useful with a long history.

    Does the history or shell have any option s to do that?


  2. Re: How to recall history command for editing

    On 14 May 2007 03:08:55 -0700, voipfc wrote:
    >
    > I am looking for a way to recall a previous history command for
    > editing, without executing it automatically.
    >
    > The up and down cursor keys are not really useful with a long history.
    >
    > Does the history or shell have any option s to do that?


    You might try the search command of your $VISUAL editor. Doing a

    $ echo $VISUAL

    on my system we see

    emacs

    so I do a Ctrl r(partial_string_2_find_here)


  3. Re: How to recall history command for editing

    On May 14, 3:08 am, voipfc wrote:
    > I am looking for a way to recall a previous history command for
    > editing, without executing it automatically.
    >
    > The up and down cursor keys are not really useful with a long history.
    >
    > Does the history or shell have any option s to do that?


    The command history is stored in ~/.bash_history. The history
    typically contains the last 500 commands typed at the shell prompt.

    Here are some tips on using the bash history.
    http://systemnotesorg.blogspot.com/2...h-history.html


  4. Re: How to recall history command for editing

    On May 15, 6:33 am, systemno...@gmail.com wrote:
    > On May 14, 3:08 am, voipfc wrote:
    >
    > > I am looking for a way to recall a previous history command for
    > > editing, without executing it automatically.

    >
    > > The up and down cursor keys are not really useful with a long history.

    >
    > > Does the history or shell have any option s to do that?

    >
    > The command history is stored in ~/.bash_history. The history
    > typically contains the last 500 commands typed at the shell prompt.
    >
    > Here are some tips on using the bash history.http://systemnotesorg.blogspot.com/2...h-history.html



    cat .bash_history | grep

    zaher el siddik
    http://elsiddik.googlepages.com/


  5. Re: How to recall history command for editing

    On May 15, 6:09 pm, elsiddik wrote:
    > On May 15, 6:33 am, systemno...@gmail.com wrote:
    >
    > > On May 14, 3:08 am, voipfc wrote:

    >
    > > > I am looking for a way to recall a previous history command for
    > > > editing, without executing it automatically.

    >
    > > > The up and down cursor keys are not really useful with a long history.

    >
    > > > Does the history or shell have any option s to do that?

    >
    > > The command history is stored in ~/.bash_history. The history
    > > typically contains the last 500 commands typed at the shell prompt.

    >
    > > Here are some tips on using the bash history.http://systemnotesorg.blogspot.com/2...h-history.html

    >
    > cat .bash_history | grep
    >
    > zaher el siddikhttp://elsiddik.googlepages.com/


    Ooops - i miss understood :x
    you can always see the command history by typing cat .bash_history -
    or if you need to see the last 20 commands or so type
    cat .bash_history | tail -n 20
    or even cat .bash_history | more

    cheers,
    zaher el siddik
    http://elsiddik.googlepages.com/


  6. Re: How to recall history command for editing

    I demand that elsiddik may or may not have written...

    > On May 15, 6:09 pm, elsiddik wrote:

    [snip]
    >> cat .bash_history | grep
    >> zaher el siddikhttp://elsiddik.googlepages.com/


    > Ooops - i misunderstood :x
    > you can always see the command history by typing cat .bash_history -
    > or if you need to see the last 20 commands or so type
    > cat .bash_history | tail -n 20
    > or even cat .bash_history | more


    And this week's 'Most Pointless Use Of cat' award goes to...

    > zaher el siddik


    ;-)

    --
    | Darren Salt | linux or ds at | nr. Ashington, | Toon
    | RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
    | + At least 4000 million too many people. POPULATION LEVEL IS UNSUSTAINABLE.

    It is now pitch dark. If you proceed, you will likely fall into a pit.

  7. Re: How to recall history command for editing

    On May 15, 10:14 am, elsiddik wrote:
    > On May 15, 6:09 pm, elsiddik wrote:
    >
    >
    >
    > > On May 15, 6:33 am, systemno...@gmail.com wrote:

    >
    > > > On May 14, 3:08 am, voipfc wrote:

    >
    > > > > I am looking for a way to recall a previous history command for
    > > > > editing, without executing it automatically.

    >
    > > > > The up and down cursor keys are not really useful with a long history.

    >
    > > > > Does the history or shell have any option s to do that?

    >
    > > > The command history is stored in ~/.bash_history. The history
    > > > typically contains the last 500 commands typed at the shell prompt.

    >
    > > > Here are some tips on using the bash history.http://systemnotesorg.blogspot.com/2...h-history.html

    >
    > > cat .bash_history | grep

    >
    > > zaher el siddikhttp://elsiddik.googlepages.com/

    >
    > Ooops - i miss understood :x
    > you can always see the command history by typing cat .bash_history -
    > or if you need to see the last 20 commands or so type
    > cat .bash_history | tail -n 20
    > or even cat .bash_history | more


    No, no and no
    You do grep ~/.bash_history, tail -n 20
    ~/.bash_history and more ~/.bash_history

    There's no reason to use cat and pipe here. Never! It's just bloody
    ugly...




  8. Re: How to recall history command for editing

    On 2007-05-15, Darren Salt wrote:
    > I demand that elsiddik may or may not have written...
    >
    >> cat .bash_history | tail -n 20
    >> or even cat .bash_history | more

    >
    > And this week's 'Most Pointless Use Of cat' award goes to...
    >
    >> zaher el siddik

    >
    > ;-)


    cat .bash_history | tail -n 20 |cat

    --keith ;-)

    --
    kkeller-usenet@wombat.san-francisco.ca.us
    (try just my userid to email me)
    AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
    see X- headers for PGP signature information


  9. Re: How to recall history command for editing

    On Tue, 15 May 2007 01:09:31 -0700, elsiddik wrote:

    >
    >
    > cat .bash_history | grep


    much ado.

    history |tail -n 20

    works to grab the last 20 lines of 'history'. this is in SuSE. maybe this
    bit is different in other distributions?

    Felmon


  10. Re: How to recall history command for editing

    On May 15, 11:25 pm, Darren Salt
    wrote:
    > I demand that elsiddik may or may not have written...
    >
    >
    >
    > > On May 15, 6:09 pm, elsiddik wrote:

    > [snip]
    > >> cat .bash_history | grep
    > >> zaher el siddikhttp://elsiddik.googlepages.com/

    > > Ooops - i misunderstood :x
    > > you can always see the command history by typing cat .bash_history -
    > > or if you need to see the last 20 commands or so type
    > > cat .bash_history | tail -n 20
    > > or even cat .bash_history | more

    >
    > And this week's 'Most Pointless Use Of cat' award goes to...
    >
    > > zaher el siddik

    >
    > ;-)
    >
    > --
    > | Darren Salt | linux or ds at | nr. Ashington, | Toon
    > | RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
    > | + At least 4000 million too many people. POPULATION LEVEL IS UNSUSTAINABLE.
    >
    > It is now pitch dark. If you proceed, you will likely fall into a pit.


    thx mate ;-)


  11. Re: How to recall history command for editing

    On May 16, 2:23 pm, felmon john davis wrote:
    > On Tue, 15 May 2007 01:09:31 -0700, elsiddik wrote:
    >
    > > cat .bash_history | grep

    >
    > much ado.
    >
    > history |tail -n 20
    >
    > works to grab the last 20 lines of 'history'. this is in SuSE. maybe this
    > bit is different in other distributions?
    >
    > Felmon


    no its not.

    zaher el siddik
    http://elsiddik.googlepages.com/


  12. Re: How to recall history command for editing

    I demand that felmon john davis may or may not have written...

    > On Tue, 15 May 2007 01:09:31 -0700, elsiddik wrote:
    >> cat .bash_history | grep


    > much ado.


    > history |tail -n 20
    > works to grab the last 20 lines of 'history'. this is in SuSE. maybe this
    > bit is different in other distributions?


    It's a bash built-in command, and the man page says that it can take a
    numeric parameter:

    $ history 20

    .... hmm, was that the cat's tail...? ;-)

    --
    | Darren Salt | linux or ds at | nr. Ashington, | Toon
    | RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
    | (PGP 2.6, GPG keys)

    What boots up must come down.

  13. Re: How to recall history command for editing

    On May 14, 11:08 am, voipfc wrote:
    > I am looking for a way to recall a previous history command for
    > editing, without executing it automatically.
    >
    > The up and down cursor keys are not really useful with a long history.
    >
    > Does the history or shell have any option s to do that?


    Thanks for all the responses, but some of them appear to be off track.

    I think I should explain better.

    Lets say I run the history command and I see that command 27 is what I
    want.

    I am looking for something like : xxx 27, so that line 27 will be on
    the prompt read for editing.

    Is there something like that. I saw the fc and ! commands, but they
    appear to execute the command
    which isn't what I want.


  14. Re: How to recall history command for editing



    voipfc wrote:

    >On May 14, 11:08 am, voipfc wrote:
    >
    >
    >>I am looking for a way to recall a previous history command for
    >>editing, without executing it automatically.
    >>
    >>The up and down cursor keys are not really useful with a long history.
    >>
    >>Does the history or shell have any option s to do that?
    >>
    >>

    >
    >Thanks for all the responses, but some of them appear to be off track.
    >
    >I think I should explain better.
    >
    >Lets say I run the history command and I see that command 27 is what I
    >want.
    >
    >I am looking for something like : xxx 27, so that line 27 will be on
    >the prompt read for editing.
    >
    >Is there something like that. I saw the fc and ! commands, but they
    >appear to execute the command
    >which isn't what I want.
    >


    If you are using bash then first do:

    shopt -s histverify

    Then when you do !27 it will put the command on the command line and
    allow you to edit it.

    Good luck,

    Steve

    P.S. This was found via the time-honored method of "man history".


+ Reply to Thread