SUMMARY:how to make substitution in files

From: Jerry Brady <jerry.brady_at_faypwc.com>
Date: Thu, 24 May 2001 08:30:52 -0400

Many thanks to:
Dr. Blinn
Bryan Dunlap
Bob Vickers
Kevin McDonnell
Nikola Milutinovic
Sreenivasa Prasad
Robert Mulley
Tom Webster

I recieved other responses that suggested I read the man page on sed. My
problem was
that I did not know how to make sed put the change back into the orginal
file. The people
listed above gave me many ways to do that in the korn shell and some perl
solutions. I feel
like a kid in a candy store right now. I will show you the korn shell
example and if you would
like to see the other ones send me an email and I will forward them to you.

for x in *
do
  echo $x
  sed -e 's/dst_prod/dst_test/g' $x > ${x}.new
  mv ${x}.new $x
done



here is one using the find command:

find . -type f -prune -exec grep -l dst_prod | while read f ; do
        sed 's/dst_prod/dst_test/g' $f > /var/tmp/$$ ; mv /var/tmp/$$ $f
        done
Again, thanks to all, this is the best mailing list!
Received on Thu May 24 2001 - 12:40:13 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:42 NZDT