2

i have the following regex command in my bash script:

 sed -i -e 's/\(expose_php = On\)/\1expose_php = Off/' /etc/php/php.ini

Instead of replacing:

  expose_php = On

with

expose_php = Off

it's doing the following:

 expose_php = Onexpose_php = Off

This is my first crack at bash and sed... any pointers would be appreciated.

1
  • You are catching expose_php = On and then printing back with \1. Commented Feb 24, 2014 at 13:30

1 Answer 1

3

You can use:

sed -i -e 's/expose_php = On/expose_php = Off/' /etc/php/php.ini

No need to capture the match and use back reference \1 in replacement in your case.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.