Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
repeat the last command with a new arguement?
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
tipp98
Tux's lil' helper
Tux's lil' helper


Joined: 28 Jan 2007
Posts: 113

PostPosted: Wed Aug 26, 2009 6:52 pm    Post subject: repeat the last command with a new arguement? Reply with quote

Anyone have any tricks on how to do this?

There is ^old^new, but sometimes I have a short memory and forget what I just typed :\

I tried making a script, but found history doesn't work inside scripts.
Code:

last=$(!!$)
^${last}^${1}
Back to top
View user's profile Send private message
truc
Advocate
Advocate


Joined: 25 Jul 2005
Posts: 3199

PostPosted: Wed Aug 26, 2009 8:01 pm    Post subject: Reply with quote

have a look at the readline manual


Code:
ls -l test/
typing C-P C-W tist will give you
Code:
ls -l tist

or you can also type
Code:
!:0 tata
ls tata


or even C-A-0 C-Y toto which will do a
Code:
ls toto



really, check the readline manual, there are a lot of valuable information:)
_________________
The End of the Internet!


Last edited by truc on Thu Aug 27, 2009 8:02 am; edited 1 time in total
Back to top
View user's profile Send private message
coolsnowmen
Veteran
Veteran


Joined: 30 Jun 2004
Posts: 1479
Location: No.VA

PostPosted: Wed Aug 26, 2009 8:10 pm    Post subject: Re: repeat the last command with a new arguement? Reply with quote

tipp98 wrote:

I tried making a script, but found history doesn't work inside scripts.

that isn't the problem. functions or aliases can get around that, the problem is your command can't work because of order of operations
the bash command substitution will not dereference a variable inside of the substitution string.

Or rather I can't get it too:
Code:
~ $ echo john
john
~ $ ^john^fred^
echo fred
fred


~ $ echo john
john
~ $ last="!!$"
last="john"
^${last}^fred^
bash: :s^${last}^fred^: substitution failed


I simply think it would be faster to do this:
try your command that you want to redo
then do Ctrl-p-w (just hit 'p' and 'w' in succession, no need to hold them down together.
_________________
emerge: there are no ebuilds to satisfy "moo"
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