I have a txt
file that looks like this:
<sss>ss<
or
<firstword>anotherword<
I want it to look like this
<sss>ss</sss>
or
<firstword>anotherword</firstword>
Basically taking the first word and placing it in an end tag.
And before you asked what I have tried, the answer is nothing, I couldn't think of anything.
Best Answer
With input:
Use:
Output:
The sed line only affects lines ending in
<
(because of the<$
) and catches the patterns between the first<>
pair and between '><' and pastes everything back in duplicating the first pair at the end (plus a closing '>')