I want to remove XML comments in bash using regex (awk, sed, grep...) I have looked at other questions about this but they are missing something. Here\'s my xml code
<
The most simple solution to remove all comments from a textfile I could come up with is:
sed 's//-->\x0/g' | grep -zv '^\0
Than the grep -z
will treat that character as "line separator"
\n
\n\n\n \n
\n
\n
grep -v
will remove the middle part.
And finally tr -d
will remove the \0
again.
In this case it should be applied to both files before comparing e.g.:
diff <(sed 's//-->\x0/g' file1.xml | grep -zv '^/-->\x0/g' file2.xml | grep -zv '^/-->\x0/g' | grep -zv '^
- 热议问题