sed

Hi all

I wrote this script to substitute new text for old text in a number of files
aaaargh been at it now for two hours. its still not working. Any idea where i am going wrong here. thanks

read OLDTEXT
read NEWTEXT

for i in $* 
do 
 sed -e "s|$OLDTEXT|$NEWTEXT|g" $i > $i 
done 

you are parsing the file and writing to it at the same time. use the -i option of sed to do inplace edit or redirect to a temp file, then rename the temp file back to original.