Skip to main content
Otherwise shell expansion won't work - Note: I kept only double quotes and will add this to the next answer, where its a comment.
Source Link
thanasisp
  • 8.5k
  • 2
  • 29
  • 40

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 :

pattern=`cat /path/to/pattern`; replacement=`cat /path/to/replacement` find . -name "*.php" | xargs -n 1 sed -i -e "s|$(cat /path/to/pattern)|$(cat /path/to/replacement)|g""s|$pattern|$replacement|g" 

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" 

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 :

pattern=`cat /path/to/pattern`; replacement=`cat /path/to/replacement` find . -name "*.php" | xargs -n 1 sed -i -e "s|$pattern|$replacement|g" 

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 :

pattern=`cat /path/to/pattern`; replacement=`cat /path/to/replacement` find . -name "*.php" | xargs -n 1 sed -i -e 's|$pattern|$replacement|g'"s|$(cat /path/to/pattern)|$(cat /path/to/replacement)|g" 

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 :

pattern=`cat /path/to/pattern`; replacement=`cat /path/to/replacement` find . -name "*.php" | xargs -n 1 sed -i -e 's|$pattern|$replacement|g' 

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" 
added 188 characters in body
Source Link
Coren
  • 5.1k
  • 1
  • 27
  • 44

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 :

pattern=`cat /path/to/pattern`; replacement=`cat /path/to/replacement` find . -name "*.php" | xargs -n 1 sed -i -e 's/foo/bar/g''s|$pattern|$replacement|g' 

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)

At the end, it should looks like :

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

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 :

pattern=`cat /path/to/pattern`; replacement=`cat /path/to/replacement` find . -name "*.php" | xargs -n 1 sed -i -e 's|$pattern|$replacement|g' 
Source Link
Coren
  • 5.1k
  • 1
  • 27
  • 44
Loading