1

In 30 files in 30 directories, I want to find:

script>');} < /script>

and replace it with:

script>');} < /script-->
  • What special characters do I need to escape in the find field?
  • Do I need to escape the same characters in the replace_with field?
  • Is backslash the appropriate escape key?

I will use the following method:

find . -type f -name "*.php" -exec sed -i 's/"find"/"replace_with"/g' {} +

That method has worked for simple replacements.

I read How can I replace a string in a file(s)?, and other pages, but could not find the answer I need.

1 Answers1

0

you can use sed -i "s+< /script>+< /script-->+g". So final command would become

find . -type f -name "*.php" -exec sed -i "s+< /script>+< /script-->+g" {} +
Rahul
  • 13,589