i have this xml text in file named test2.txt
<This is a line of text with a year=2020 month=12 in it
This line of text does not have a year or month in it
This year=2021 is the current year the current month=1
This is the year=2021 the month=2/>
<This is a line of text with a year=33020 month=12 in it
This line of text does not have a year or month in it
This year=33020 is the current year the current month=1
This is the year=33020 the month=2/>
im running this regexp on the file : i like to commnet the first paragraph but leaving the rest of the file as is
sed -i -En '/./{H;$!d} ; x ; s/<(This.*2020.*)\/>/<!--\1-->/p' test2.txt
but the result is that the sed command removing all the rest of the string in the file and putting the result of the regexp init so now the test2.txt looks like this :
<!--This is a line of text with a year=2020 month=12 in it
This line of text does not have a year or month in it
This year=2021 is the current year the current month=1
This is the year=2021 the month=2-->
how can i run the regexp but leave the other text in the file ?