bash history use and abuse

Discussion in 'Linux' started by jimkd1yv, Jan 18, 2012.

  1. jimkd1yv

    jimkd1yv Well-Known Member

    Joined:
    Jul 6, 2010
    Messages:
    65
    Likes Received:
    1
    As promised, attached is the document with the bash history topics that I presented at tonight's meeting.

    Holler if you have any questions.

    Jim
     

    Attached Files:

  2. madmod

    madmod Member
    SIG Leader

    Joined:
    Sep 8, 2008
    Messages:
    13
    Likes Received:
    0
    Great post. Thanks.

    I messed around with almost all of the commands but subsitituted as follows:

    First give the following command:
    ls Documents Downloads Music Pictures Public
    Next, to reference only Downloads and Music:
    ls -l !-1:2-3 go back one command, list contents of the 2nd, 3rd folders (Download, Music)

    This seemed to work for me. I think the !-3 in the notes caused a problem. I remember you used some kind of work-around when you presented the topic.

    Haven't got the search stuff with CTRL+R quite yet. It went too quickly on my computer to see what was happening. Perhaps I can work on that later.
     
  3. jimkd1yv

    jimkd1yv Well-Known Member

    Joined:
    Jul 6, 2010
    Messages:
    65
    Likes Received:
    1
    In this command, the !-n refers to the nth-previous command. When I wrote the text in the document, I had issued 2 more commands in between the one of interest and the !-n . If you want to reference the immediately previous command, you could do
    ls -l !-1:2-3
    and it should work.

    Jim
     

Share This Page