Skip to main content

It can be done easily with a good combination of sed and xargs.

find . -name "*.php" | xargs -n 1 echo 

will show you the power of xargs.

After that, on a sample file, you can test the regexp, with an inplace change (-i) or a backup change (-i.bak). You can also use an other character to replace '/' if your pattern/replacement already have one.

At the end, it should looks like :

find . -name "*.php" | xargs -n 1 sed -i -e "s|$(cat /path/to/pattern)|$(cat /path/to/replacement)|g" 
Coren
  • 5.1k
  • 1
  • 27
  • 44