Hello,
I was wondering if you could help me to make a script to edit a particular word in many many files, I came up with the search line but I don`t know how to replace the particular word with mine.
the search line is:
find /srv/www/htdocs/ -exec grep dog.org {} \; -print
dog.org must be replaced with dog.com
Thank you in advance!
You can also use ex (vi’s alter ego) to edit files in place. You don’t even have to put the commands in a script, you can use a here document. E.g.
for f in *.txt
do
ex "$f" <<EOF
g/dog\.org/s//dog.com/g
x
EOF
done
You can substitute that *.txt with a backticked command like find /var/www/htdocs -type f
.
Thank you very much for your reply, it`s very helpful.