I have 100+ jinja template files with 0-k occurrences of "value: ..." string in each of them. The problem is that some of the files are using:
value: something
some of them:
value: 'something'
and some of them:
value: "some other thing"
I need all of these to look the same, to use double quotes. I thought I'd do it with sed:
sed -i 's/value: ['"]?(.*)['"]?/value: "\1"/g' *.j2
but as you can see I'm quite horrible with sed and the past 2 hours only made me want to break my keyboard with the nonsense error messages I'm getting, like: unterminated `s' command and such.
Sample input:
- param:
name: Command
type: String
value: '/bin/echo'
- param:
name: Args
type: String
value: Hello World
- param:
name: Something
type: EnvVar
value: "PATH"
from this I need to get:
- param:
name: Command
type: String
value: "/bin/echo"
- param:
name: Args
type: String
value: "Hello World"
- param:
name: Something
type: EnvVar
value: "PATH"
"value"
in quotes as well? Best thing is give us a sample of input and expected output – GMaster Sep 21 '20 at 10:39sed
program enclosed in single quotes. This will not work. You can replace the literal single quotes in your regular expression with\x27
instead. – AdminBee Sep 21 '20 at 10:40