View previous topic :: View next topic |
Author |
Message |
rshea n00b
Joined: 08 Feb 2006 Posts: 15 Location: Wellington, NZ
|
Posted: Wed Apr 19, 2006 3:45 am Post subject: [SOLVED] HISTORY - review command before executing ? |
|
|
Hi - i've only just discovered the HISTORY command in BASH which i really like.
What I'd really like to be able to do that i cannot at the moment is type something like :
myprompt>!foo
... but instead of the most recent command starting with the string foo being executed I'd like it to sit there so that I can (A) check it's the one i want and (B) modify it if necessary
I presume this must be possible but I cannot work out how to do it from the man page (which gets rather carried away about substitutions - i want something simpler than that I think).
regards
richard.
Last edited by rshea on Wed Apr 19, 2006 8:41 am; edited 1 time in total |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20067
|
Posted: Wed Apr 19, 2006 3:50 am Post subject: |
|
|
Try Ctrl-R followed by typing the command you want. As you type, it offers suggestions. When you have the command you want, the right arrow key will put it onto the prompt.
Also, 'man history' offers a solution to what you're after for the history command. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
rshea n00b
Joined: 08 Feb 2006 Posts: 15 Location: Wellington, NZ
|
Posted: Wed Apr 19, 2006 4:03 am Post subject: |
|
|
Hi Thanks for the ctrl-R thing - what's that called, i'd like to read more about it (man reverse-i-search doesn't get me anything
I would rather use history anyway. You say it's in the man page the nearest i can see is this ...
p Print the new command but do not execute it.
... but it doesn't make it very clear how you use modifiers. I tried ...
myprompt>!foo :p
... but that executes the last command starting 'foo' with an argument of ':p'.
Can you give me a bit more please ?
thanks
richard. |
|
Back to top |
|
|
Nil_Spaar Apprentice
Joined: 10 Jul 2004 Posts: 179 Location: Berlin, Germany
|
Posted: Wed Apr 19, 2006 6:01 am Post subject: |
|
|
You could use the "Page-Up" key. When you type e.g. "ssh " and hit "Page-Up" it will cycle through the history but only those lines that start with "ssh ". |
|
Back to top |
|
|
rshea n00b
Joined: 08 Feb 2006 Posts: 15 Location: Wellington, NZ
|
Posted: Wed Apr 19, 2006 8:40 am Post subject: |
|
|
That's great, that's just what I wanted to do - thanks very much.
richard. |
|
Back to top |
|
|
|