ed problem
dinah at krebs.bcm.tmc.edu
dinah at krebs.bcm.tmc.edu
Thu Aug 31 09:43:00 AEST 1989
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 at bcm.tmc.edu
Baylor College of Medicine uucp: {rutgers,mailrus}!bcm!dinah
More information about the Comp.unix.questions
mailing list