Register
It is currently Fri Oct 24, 2014 7:30 am

Executing Commands from History with !


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Wed Apr 30, 2014 10:09 pm   
User avatar

Joined: Sat Dec 11, 2010 5:27 pm
Posts: 15
Location: NSW, Australia
Silly question probably but...

I can execute commands from the history file by using ! - eg !123

This runs the command 123 immediately. How can I recall the command without executing it so that I can edit the command?

I should know the answer to something like this!!!'


TIA

Alan


Top
 Profile  
 PostPosted: Thu May 01, 2014 4:32 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Well ctrl-r can help but what you're actually after is more like this;
Code:
!ssh:p

the :p indicates you only want it printed rather than run.

If you have the histverify option set (shopt -s histverify), you will always have the opportunity to edit the result of history substitutions.


Top
 Profile  
 PostPosted: Thu May 01, 2014 7:19 pm   
User avatar

Joined: Sat Dec 11, 2010 5:27 pm
Posts: 15
Location: NSW, Australia
Thanks Darth

The shopt -s histverify is what I wanted

Alan


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 23 guests


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 post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP