0

I succeeded to use sed -i on Linux to modify a JSON value in a file.

$> sed -i '/brand/c\   \"brand\": \"'valueModified'\"' ./config/brand.config.json

But on MacOS I get:

sed: 1: "./config/brand.config.json": invalid command code .

I'm trying to use this command in a shell script on linux and macOS.

Thank you

FlorentGui
  • 113
  • 1
  • 7

1 Answers1

0

POSIX sed implementations allow for the I line replacement where non-POSIX UNIX implementations do not. OSX, like BSD implentations can be accomplished like so :

cp -p ./config/brand.config.json ./config/brand.config.json.tmp;
sed '/brand/c\   \"brand\": \"'valueModified'\"' ./config/brand.config.json.tmp > ./config/brand.config.json
Aserre
  • 4,916
  • 5
  • 33
  • 56
jas-
  • 1,801
  • 1
  • 18
  • 30