Bash - Find and replace string in multiple files
How to replace string in multiple files using command line?
1. Option #1
To replace foo to bar in all files in current directory (it will not search files in sub folders)
sed -i 's/foo/bar/g' *
2. Option #2
To replace foo to bar in all files recusrively
find . -type f -exec sed -i 's/foo/bar/g' {} +
Find can accept multiple arguments to filter down necessary files e.q. - to find just PHP files
find . -type f -name '*.php' -exec sed -i 's/foo/bar/g' {} +