Reputation: 137
I have a minor problem. I want to replace a character/single string between two strings but would like to leave the strings themselves "unharmed" by using sed.
The input is:
<hello> <world>
My desired output:
<hello>
<world>
My first attempt:
echo "<hello> <world>" | sed 's/>.</\n/g'
The output of it:
<hello
world>
As you can see, the ">" from "" and the "<" from "" have been removed by using my line above.
How do I prevent it from doing so?
Upvotes: 0
Views: 59
Reputation: 66
Instead use:
echo "<hello> <world>" | sed 's/>.</>\n</g'
This is possible all the characters you are replacing are static.
Upvotes: 1