Replace string in all files using sed in linux

by

in

Replaces all “OLDSTRING” to “NEWSTRING” in all files

$ grep -rl OLDSTRING * | sort | uniq | xargs sed -i -e ‘s/OLDSTRING/NEWSTRING/’

or using find:

find */public_html/ -iname '*.php' -exec sed -i -e 's/OLDSTRING/NEWSTRING/' {} \;

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.