I have one file having following example text.
"list-value": {
"object-value": {
"value": "example-value-123"
}
}
I want to change value text "example-value-123" by matching pattern from list-value with value text "example-value-changed-567"
Example
"list-value": {
"object-value": {
"value": "example-value-changed-567"
}
}
I don't want to match text pattern starting from value. I have to match pattern starting from list value. I have tried to create regular expression but not able to match pattern after new line found.
Regular expression I have tried so far
$ sed -i 's/ [[:space:]]\"list-value\":[[:space:]]{[[:space:]]N;[[:space:]]\"objet-value\"[[:space:]]:[[:space:]]\"[\w+\W+]+\"[[:space:]]} / [[:space:]]\"list-value\":[[:space:]]{[[:space:]]N;[[:space:]]\"objet-value\"[[:space:]]:[[:space:]]\"example-value-changed-567\"[[:space:]]}/g' file.json
I am getting below error for above command
sed: 1: "file. ...": command a expects \ followed by text
I have created one regular expression online but it is not woking with sed command.
\s+"list-value":\s+{\s+"value"\s*:\s+"[\w+\W+]+"\s+}
I need to find better and working regular expression for sed command.
{...}
). You also fail to say in what way your attempt failed.