I'm hoping someone can tell me what I'm doing wrong. I have a line in a lot of HTML files that I'd like to remove. The line is:

            <hr  style="border-top: 1px solid rgb(0, 32, 159); margin: 0rem;">

I'm testing the sed command to remove it on just one file. When it works, I'll run it against *.html. My command is:

 sed -i -s 's/\s*\<hr\ \ style.*\>//g' history.html

Unfortunately, the replacement doesn't remove the line but rather leaves me with:

            <;">

The leading spaces, angle brackets and some punctuation (but not all) is left behind. Moreover, If I try to remove the EOL by adding \n after the \>, the replace fails (and yes, the closing bracket is the last character on the line).

I get the same behaviour under both Bullseye and Bookworm so I assume this is how sed is supposed to operate. However, when I try the same regex in Kate, it works.

Is this a long-standing bug in sed or am I doing something wrong?

Thanks

Reply via email to