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?
这个也可以:
echo "<hello> <world>" | sed 's/>./>\n/g'
Instead use:
echo "<hello> <world>" | sed 's/>.</>\n</g'
This is possible all the characters you are replacing are static.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.