How to edit a prior command
Gerry Paul
gpaul at opus.cdc.com
Sat Mar 18 09:16:10 AEST 1989
... while trying to learn more about csh and shell scripts...
What I would like to do is to edit a previous entry on the history list
and execute it, much as I can on a Symbolics machine.
The closest I am able to do is to make one change to a prior command.
Eg history ...4 echo 'fred'
5 ....
I can do a !4:s/fred/wanda which executes echo 'wanda'
To "simplify" this, I would like to create a shell command which would
do the same thing so I could enter (the admittedly not much simpler)
h 4 /fred/wanda instead of !4:s/fred/wanda
My unsuccessful attempts look like this
alias h '!\!^:s\!$'
While I don't think I have the quotes, backquotes, etc right yet, a bigger
problem seems to loom in the evaluation sequence. First I need the
history entry number from the prior command, ie, !^ or 4 in this
example. Then I need to prepend the ! to get the !4 command...
Can I do this within csh? Can I use EVAL in this?
Also, is there a more general way to re-edit a prior entry?
Gerry Paul INTERNET: gpaul at shamash.cdc.com
UUCP: {rosevax,umn-cs,bungia,ems}!shamash!gpaul
Gerry Paul INTERNET: gpaul at shamash.cdc.com
UUCP: {rosevax,umn-cs,bungia,ems}!shamash!gpaul
More information about the Comp.unix.questions
mailing list