Path: utzoo!attcan!uunet!husc6!mailrus!ncar!tank!shamash!opus.cdc.com!gpaul From: gpaul@opus.cdc.com (Gerry Paul ) Newsgroups: comp.unix.questions Subject: How to edit a prior command Message-ID: <11877@shamash.cdc.com> Date: 17 Mar 89 23:16:10 GMT Sender: news@shamash.cdc.com Reply-To: gpaul@opus.cdc.com (Gerry Paul ) Organization: Control Data Corporation, Bloomington, MN Lines: 33 ... 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@shamash.cdc.com UUCP: {rosevax,umn-cs,bungia,ems}!shamash!gpaul Gerry Paul INTERNET: gpaul@shamash.cdc.com UUCP: {rosevax,umn-cs,bungia,ems}!shamash!gpaul