Escape <and> in sed / shell

How can I escape '<' and '>' in sed.

I have some XML files that need some text between the tags that need to be replaced. How can I avoid the ">" and "<" characters.

Problem s> and <this is of particular importance in the shell for redirecting output to a file. So the backslash doesn't work.

+3
source share
3 answers

Ok I discovered it myself. Use quotation marks.

$ sed -i "s/>foo</>bar</g" file
+5
source

Backslash Escape

0
source

. , , , . sed XML , ? :

sed -re '[email protected](<TAG.*?>).*?(</TAG>)@\1hi\[email protected]' test.xml
0

Source: https://habr.com/ru/post/1697717/


All Articles