Home > Enterprise >  Uncomment line using sed
Uncomment line using sed

Time:01-11

How can I uncomment a line // Configure::write('debug', 2); using sed? I've tried

sed 's // Configure::write('debug', 2); Configure::write('debug', 2); g' -I file

CodePudding user response:

The problem is you are using single quotes both to denote the argument and you have them inside the string you are trying to match, so the shell just strips them, and the match fails.

Use double quotes around the argument:

sed "s // Configure::write('debug', 2); Configure::write('debug', 2); g" -i file

Note that depending on the version of sed you are using, you may need to escape the parentheses so they are not treated as a capture group.

I tested with GNU sed version 4.7 and it is not needed, the example above works, but it also expects a lower case i as the "in place" parameter.

  •  Tags:  
  • Related