Recursive Find & Replace

Run String Replace on an entire Directory

This Linux command can be very handy for doing things like migrating sites from staging to production by making it easy to update things like URL and base paths.

Below we search recursively through the /var/www/mysite folder and replace every occurence of /var/www/dev_mysite/ with /var/www/mysite/.

grep -rl \/var\/www\/dev_mysite\/ /var/www/mysite/ | xargs sed -i "" 's/\/var\/www\/dev_mysite\//\/var\/www\/mysite\//g'

Comments (0)

Add a Comment

Allowed tags: <b><i><br>Comment:

** Time spent on this website is non-refundable **