Replace string in multiple files - Command line

Go to directory that contain files.

cd /var/www/posts

Find all PHP files in that folder & replace string foo with bar in all files.

find . -name "*.php" -print | xargs sed -i 's/foo/bar/g'

Need Help?

Do you need any help on Linux & Linux Commands? I'm happy to help you.

Contact Me