2014-05-22 3 views
2

일부 데이터에서 xpath를 수행하기 위해 bash 스크립트에서 xmllint를 사용하고 있습니다. xpath가 항상 데이터와 일치하는 것은 아니며 괜찮습니다. xmllint가 문서에서 : xmllint가 어떤 경기를 찾을 수없는 경우xmllint xpath 빈 세트에서 오류를 인쇄하지 않습니다.

--xpath "XPath_expression" 
     Run an XPath expression given as argument and print the result. In case of a nodeset result, each node in the node set is serialized in full in the output. In case of an empty node set the "XPath set is 
     empty" result will be shown and an error exit code will be returned. 

출력 XPath set is empty을 숨길/비활성화 어쨌든이 있나요?

+0

하면 오류 메시지가 stderr에 기록되어 있는지 확인 했습니까? 'xmllint ... 2>/dev/null'을 사용하여 모든 오류 메시지를 버리거나'xlmlint ... 2> & 1 | '과 같이 출력을 병합 할 수 있습니다 (stdout과 stderr의 구분을 잃어 버릴 수 있습니다). egrep -v 'XPath 세트가 비어 있습니다. 아마도 당신이 걱정하지 않는 다른 메시지 일 것입니다. 행운을 빈다. – shellter

답변

4

메시지가 표준 오류 장치로 이동합니다. 이것을 /dev/null으로 재전송 할 수 있습니다.

예 :

# Shows the message 
xmllint --xpath '//a' <(echo "<data/>") 

# Redirects the message. Message disappears 
xmllint --xpath '//a' <(echo "<data/>") 2>/dev/null 
+0

그게 해결되었습니다, 고마워요! – Josh

관련 문제