You can instead of rm -f redo-afn2-dev.out; ./redo.sh afn2-dev & jobs -x tail --pid %./redo.sh -F -n +0 redo-afn2-dev.out
Type h=afn2-dev; rm -f redo-$h.out; ./redo.sh $h & jobs -x tail --pid %./redo.sh -F -n +0 redo-$h.out Then, when you need change hostname you find this command and just change h= Valery --- On Mon, 8/18/08, Amos Shapira <[EMAIL PROTECTED]> wrote: > From: Amos Shapira <[EMAIL PROTECTED]> > Subject: global interactive search-and-replace in bash? > To: "IGLU Mailing list" <linux-il@cs.huji.ac.il> > Date: Monday, August 18, 2008, 10:35 AM > Hello, > > I have this long command line which I keep changing > multiple instances > of host names in it: > > # rm -f redo-afn2-dev.out; ./redo.sh afn2-dev & jobs -x > tail --pid > %./redo.sh -F -n +0 redo-afn2-dev.out > > I use CentOS 5 and Bash as my interactive shell. > > The problem is that just *sometimes* (most of the time > it's in the > history already so no need) I want to use the last such > sequence and > replace all the host name occurances by another host. > > Using history substitution, I can do something like: > > # !rm:gs/afn2/portal2/ > > and get it done. > > But the problem is that in order to do this, I need to > search for the > last relevant command in the history, which I use > "incremental search > backwards" for (Ctrl-R). > > But once the wanted command is the current one - I > can't use the > history substitution on it. > > I found that I can refer to the current command with > "!#:", so it'll look like: > > # rm -f redo-afn2-dev.out; ./redo.sh afn2-dev & jobs -x > tail --pid > %./redo.sh -F -n +0 redo-afn2-dev.out!#:gs/afn2/portal2/ > > Then I can type M-C-e (alt-control-e) to copy the command > line as it > was typed so far into another version with the history > substitution > done on it, BUT - that leaves me with two copies of the > line: > > # rm -f redo-afn2-dev.out; ./redo.sh afn2-dev & jobs -x > tail --pid > %./redo.sh -F -n +0 redo-afn2-dev.outrm -f > redo-afn1-dev.out; > /redo.sh afn1-dev & jobs -x tail --pid %./redo.sh -F -n > +0 > redo-afn1-dev.out > > (notice the "...dev.outrm -f..." in the middle of > that last line). > > Does anyone know how can I achieve the same effect without > having to > go back to the middle of the line and carefully remove the > "old" copy? > > Maybe a way to tell the shell - "ok, I like the > command I found, just > make it the last in the history without executing it", > something that > can be done with history-substitution ":p" > modifier, then I can get > back to using "!!:gs///". > > I couldn't find a solution in bash's manual or FAQ. > > I'd rather have something usable from the interactive > command line and > not a script since such a typing trick can come handy in > multiple > situations, the above is just an example. > > Thanks, > > --Amos > > ================================================================= > To unsubscribe, send mail to [EMAIL PROTECTED] > with > the word "unsubscribe" in the message body, e.g., > run the command > echo unsubscribe | mail [EMAIL PROTECTED] ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]