Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash xmllint xpath don';t在空集合上打印错误_Bash_Xmllint - Fatal编程技术网

Bash xmllint xpath don';t在空集合上打印错误

Bash xmllint xpath don';t在空集合上打印错误,bash,xmllint,Bash,Xmllint,我在bash脚本中使用xmllint对一些数据执行xpath。xpath并不总是与数据匹配,这是可以的。从xmllint文档: --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 outp

我在bash脚本中使用xmllint对一些数据执行xpath。xpath并不总是与数据匹配,这是可以的。从xmllint文档:

--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.

当xmllint没有找到任何匹配项时,是否仍有方法禁用/隐藏输出
XPath集为空
。您可以将其重定向到
/dev/null

例如:

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

# Redirects the message. Message disappears
xmllint --xpath '//a' <(echo "<data/>") 2>/dev/null
#显示消息
xmllint--xpath'/a'/dev/null

您确认错误消息已写入stderr了吗?您可以使用
xmllint放弃所有错误MSG。。。2> /dev/null
或合并输出(失去stdout和stderr之间的区别),如
xlmlint。。。2> &1 | egrep-v’XPath集为空|可能是您不关心的其他MSG’
祝您好运。