Skip to main content
add modification from comment to match how we get pattern/replacement from files
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40

Try:

find . -name "*.php" -exec sed -i "s/$pattern$(cat /$replacementpath/to/pattern.txt)/$(cat /path/to/replacement.txt)/g" {} \; 

where pattern is the pattern to search for and replacement is the text to replace it with.

The -i option for sed edits the files "in place". If you want to create a backup of the file before you edit it, use -i'.bak'.

Try:

find . -name "*.php" -exec sed -i "s/$pattern/$replacement/g" {} \; 

where pattern is the pattern to search for and replacement is the text to replace it with.

The -i option for sed edits the files "in place". If you want to create a backup of the file before you edit it, use -i'.bak'.

Try:

find . -name "*.php" -exec sed -i "s/$(cat /path/to/pattern.txt)/$(cat /path/to/replacement.txt)/g" {} \; 

where pattern is the pattern to search for and replacement is the text to replace it with.

The -i option for sed edits the files "in place". If you want to create a backup of the file before you edit it, use -i'.bak'.

Source Link
dogbane
  • 30.8k
  • 17
  • 85
  • 61

Try:

find . -name "*.php" -exec sed -i "s/$pattern/$replacement/g" {} \; 

where pattern is the pattern to search for and replacement is the text to replace it with.

The -i option for sed edits the files "in place". If you want to create a backup of the file before you edit it, use -i'.bak'.