for y in `ls | grep .html`;
do sed “s/abc/xyz/g” $y > temp; mv -f temp $y;
done
Script for replacing a string in multiple files
Share This Story, Choose Your Platform!
One Comment
Leave A Comment
You must be logged in to post a comment.
for y in `ls | grep .html`;
do sed “s/abc/xyz/g” $y > temp; mv -f temp $y;
done
You must be logged in to post a comment.
Hello,
First: nice blog.
Second: You don’t need to use temporary file. Sed with option -i (in-place) can do all things at once in files. More info here http://www.gnu.org/software/sed/manual/sed.html