-1

Trying to figure out how to use a sed command to replace a value when the string i am searching for has double-quotes as part of the string.

I have a config file called ABC.conf that list out the release version like so; "ReleaseSequence": 1555

I want to use sed to change the release number to 2053

I have tried the following sed command;

sed -i 's:"ReleaseSequence":.*:"ReleaseSequence": 2053:' ABC.conf

I get the error message;

sed: -e expression #1, char 24: unknown option to `s'

I have tried to escape the doubel-quotes with [\"], '"""', and "" but sed doesn't like any of those.

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
Noob
  • 1
  • 1
  • 2
  • 1
    You should not use `:` as the delimiter for `s` when you are trying to match a `:`. Just do `s/\("ReaeaseSequence":\).*/\1 2053/` – William Pursell Oct 31 '19 at 16:31

1 Answers1

0

The double quotes are not the problem here. You have used : as the separator although your data also contains literal colons. Use a different separator

sed -i 's#"ReleaseSequence":.*#"ReleaseSequence": 2053#' ABC.conf

or backslash-escape the literal colons.

tripleee
  • 175,061
  • 34
  • 275
  • 318