find and replace recursively within a directory
is there a program to find and replace text recursively of all files within a directory ?
is there an awk script to do such a thing?
Thanks.
~ Clay
September 17, 2005 10:03 PM
This should work:
for f in dir/*
do
cat $f |sed 's/old/new/g' > $f
done
Replace "dir" "old" and "new" with your own values.
You can type that right in a terminal or put it into a shell script.
for f in dir/*
do
cat $f |sed 's/old/new/g' > $f
done
Replace "dir" "old" and "new" with your own values.
You can type that right in a terminal or put it into a shell script.
Quote: Original post by Anonymous Poster
cat $f |sed 's/old/new/g' > $f
Rather use
sed -i 's/old/new/g' $f
-i for in place.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement