3

I am trying to use the Linux sed command to replace associative array values in a PHP config file. On macOS everything goes ok, but on linux I am getting an error.

Command

sed -i .back "s/'param'.*=>.*/'param' => 'value',/" config.php

Error (linux): sed: -e expression #1, char 1: unknown command: `.'

What proper solution would there be to replace PHP array values with the sed command?

1
  • show a fragment of your config file with associative array values to replace Commented Sep 4, 2017 at 7:57

1 Answer 1

2

There must be no space between -i and .back on GNU sed:

sed -i.back 's/.../.../' file

If you don't care about the backup file you can omit the option value completely on GNU sed:

sed -i 's/.../.../' file
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.