Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

History Expansion in script

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
Agvaniot
Posts: 42
Joined: 2017-07-26 13:07

History Expansion in script

#1 Post by Agvaniot »

hi. im trying to create a script that just do that :

Code: Select all

^string1^string2
the problem is when im trying to do :

Code: Select all

^$1^$2
the script try to look for a command with that parameters but i want the script to act like i typed it directly to the shell
thanks in advance!

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: History Expansion in script

#2 Post by debiman »

what is the '^' supposed to be? Ctrl key? Tab? i don't really understand which shell behavior you want to reproduce.
isn't there a history command?
what exactly are you trying to achieve?

Agvaniot
Posts: 42
Joined: 2017-07-26 13:07

Re: History Expansion in script

#3 Post by Agvaniot »

debiman wrote:what is the '^' supposed to be? Ctrl key? Tab? i don't really understand which shell behavior you want to reproduce.
isn't there a history command?
what exactly are you trying to achieve?

Code: Select all

^string1^string
is a history expansion which substitute string1 with string2 of the last command
now im trying to create a script to do just that but instead of typing ^string1^string2
i want

Code: Select all

swi string1 string2 
as its more convinient for me

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: History Expansion in script

#4 Post by debiman »

no answer on stackoverflow either... i'm guessing it isn't possible.
sure, you could try messing around with xdotool or some such, but really it would be bets to
either
- just use the history expansion as is without scripting it
or
- recreate the behavior with other utilities like sed...

you can also try to ask this on #bash on irc.freenode.net

Post Reply