Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!bcm!krebs.bcm.tmc.edu!dinah From: dinah@krebs.bcm.tmc.edu Newsgroups: comp.unix.questions Subject: ed problem Message-ID: <1685@gazette.bcm.tmc.edu> Date: 30 Aug 89 23:43:00 GMT Sender: usenet@bcm.tmc.edu Reply-To: dinah@krebs.bcm.tmc.edu () Distribution: usa Organization: Baylor College of Medicine, Houston, Tx Lines: 26 I am having problem with the following script. I want to edit some c files that begin with AA_. I and to change all combinations of AA_ to the corresponding BB_. I know there is a more efficient way to do it but the following should work. The problem seems to be that the edit works successfully, but the file does not get written back with the changes. It worked for a the first few times (I invoked the script repeatedly until all occurences were changed. I know it's crude. :-)) Any way the script prints the changes correctly, but they just don't get written back! Any ideas on what is going wrong? #! /bin/sh for files in `grep -i AA_ *.c | awk -F: '{ print $1 }' | sort -u` do ed $files << EOF /aa_/ s/aa_/bb_/p /AA_/ s/AA_/BB_/p /Aa_/ s/Aa_/Bb_/p w $files q EOF done Dinah Anderson internet: dinah@bcm.tmc.edu Baylor College of Medicine uucp: {rutgers,mailrus}!bcm!dinah