I have text file, and in it has a block that has pattern like below:
# cat file
Jit .... enabled=false
Jit ..shoes.. From=2021-01-01
Jit ..gloves.. From=2021-01-01
so I want to change all of these matching regex, wrote a sed file with these lines.
# cat sedfile
/^Jit/ {
s/enabled=false/enabled=true/g
s/From=\d+-\d+-\d+/From=2021-02-01/g
}
Pattern /^Jit/
greps lines only starting with Jit and other steps do substitutions.
Date can be anything, so I can't hardcode these, therefore matching a pattern is required.
Desired Ouput:
Jit .... enabled=false
Jit ..shoes.. From=2021-01-01
Jit ..gloves.. From=2021-01-01
g
flag, since you are performing one substitution per line. What should be the desired output? – schrodingerscatcuriosity Oct 05 '21 at 08:05\d
with[0-9]
sincesed
doesn't understand\d
. – terdon Oct 05 '21 at 08:13not-enabled=true
? Should that be changed? But anyway, since you still only show one pattern per line, it looks like you don't needg
which is only useful if you want to make multiple substitutions on the same line. – terdon Oct 05 '21 at 08:18