Structurally Sound Treehouse

just some more awesome

    • Edit
    • Delete
    • Tags
    • Autopost

    control-r for bash interactive search

    Searching the Command History

    One of the greatest features of the bash shell is command history, which makes it easy to navigate through past commands by navigating up and down through your history with the up and down arrow keys. This is fine if the command you want to repeat is within the last 10–20 commands you executed, but it becomes tedious when the command is 75–100 commands back in your history.

    To speed things up, you can search interactively through your command history by pressing Ctrl-R. After doing this, your prompt changes to:

    (reverse-i-search)`':


    Start typing a few letters of the command you're looking for, and bash shows you the most recent command that contains the string you've typed so far. What you type is shown between the ` and ' in the prompt. In the example below, I typed in htt:

    (reverse-i-search)`htt': rpm -ql $(rpm -qa | grep httpd)


    This shows that the most recent command I typed containing the string htt is:

    rpm -ql $(rpm -qa | grep httpd)


    To execute that command again, I can press Enter. If I want to edit it, I can press the left or right arrow key. This places the command on the command line at a normal prompt, and I now can edit it as if I just typed it in. This can be a real time saver for commands with a lot of arguments that are far back in the command history.

    via linuxjournal.com

     

    • 12 November 2009
    • Views
    • Permalink
    • Tweet
    • 0 responses
    • Like
    • Comment
  • Fred Lee's Space

    CTO/CIO. Ruby. Rails.

  • About Fred Lee

    CTO/CIO. Ruby. Rails.

  • Subscribe via RSS

    Archive

    2011 (21)
    June (3)
    May (5)
    April (5)
    March (2)
    February (3)
    January (3)
    2010 (27)
    November (2)
    October (1)
    September (2)
    August (3)
    July (2)
    June (3)
    May (3)
    April (5)
    February (4)
    January (2)
    2009 (89)
    December (7)
    November (6)
    October (4)
    September (10)
    August (5)
    July (6)
    June (1)
    May (3)
    April (7)
    March (5)
    February (12)
    January (23)
    2008 (12)
    December (12)
  • Follow Me

      TwitterFlickr

Theme created for Posterous by Obox