부분 이름을 기반으로 XML 파일 수정

부분 이름을 기반으로 XML 파일 수정

나는 사용해왔다Xmlstarlet일부 .xml파일을 수정했지만, 부분 이름을 기반으로 태그를 수정하는 방법을 알아내느라 헤매었습니다. <로 시작하고 끝나는 전체 줄을 주석 처리하는 가장 좋은 방법은 무엇입니까?>spiral

답변1

나는 사용할 것이다sed이 작업의 경우:

sed -r -e 's/^<(.*spiral.*)>$/<!--\1-->/'

데모:

$ cat test.xml 
<some line here>
<other spiral line here>
$ sed -i -r -e 's/^<(.*spiral.*)>$/<!--\1-->/' test.xml 
$ cat test.xml 
<some line here>
<!--other spiral line here-->

관련 정보