I have multiple HTML files in a folder. there is a <h2> tag like this:
in each file.
I want to write a shell script/batch file to add this tag in <head> section of each file:
Code:
<!-- TITLE= "same text from h2 tag" -->
Note that <h2>some text</h2> in some files has 1 or more linebreaks and so I couldn't capture tag content using a simple grep or...
for example:
<h2>first part of text
second line of text</h2>
The line break shouldn't be shown in <!-- TITLE= "same text from h2 tag" -->.
The script has to capture tag content & skip line breaks.
Can anybody help me?