I have the following file:
2020-04-17 10:35:08.339 msw_im.c wync_ua[0]DEBUG: .mark1: lorem ipsum
dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren
2020-04-17 10:35:08.340
I want to have every char between "mark1:" and and "2020-04-17 10:35:08.340" replaced like this
2020-04-17 10:35:08.339 msw_im.c wync_ua[0]DEBUG: .mark1: xxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx
xxxxx
xxxxxxxx
xxxxxxx
2020-04-17 10:35:08.340
How can I do this? I have tried:
$: sed -i '/mark1/,/^$/{s/./x/g}' file
which works, but also replaces the beginning of the 1st line with "x". I tried multiple other things w/o success. Any idea?
Anonymizing lines with GNU sed:
sed -E -i '/mark1:/,/^$/{ /mark1:/{ :a;s/(mark1:x*)[^x]/\1x/;ta;b }; s/./x/g }' file
Output to file:
2020-04-17 10:35:08.339 msw_im.c wync_ua[0]DEBUG: .mark1:xxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2020-04-17 10:35:08.340
See: man sed
and The Stack Overflow Regular Expressions FAQ