Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] HISTORY - review command before executing ?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
rshea
n00b
n00b


Joined: 08 Feb 2006
Posts: 15
Location: Wellington, NZ

PostPosted: Wed Apr 19, 2006 3:45 am    Post subject: [SOLVED] HISTORY - review command before executing ? Reply with quote

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
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20067

PostPosted: Wed Apr 19, 2006 3:50 am    Post subject: Reply with quote

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
View user's profile Send private message
rshea
n00b
n00b


Joined: 08 Feb 2006
Posts: 15
Location: Wellington, NZ

PostPosted: Wed Apr 19, 2006 4:03 am    Post subject: Reply with quote

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
View user's profile Send private message
Nil_Spaar
Apprentice
Apprentice


Joined: 10 Jul 2004
Posts: 179
Location: Berlin, Germany

PostPosted: Wed Apr 19, 2006 6:01 am    Post subject: Reply with quote

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
View user's profile Send private message
rshea
n00b
n00b


Joined: 08 Feb 2006
Posts: 15
Location: Wellington, NZ

PostPosted: Wed Apr 19, 2006 8:40 am    Post subject: Reply with quote

That's great, that's just what I wanted to do - thanks very much.

richard.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum