mai*_*ash 5 xml linux bash solaris
我使用命令 xmllint 来验证 Linux 机器上的 xml 文件
我需要的是静默模式没有输出,并且我的验证将仅使用退出代码($?)
正如我们在这里看到的,当 xml 错误时,即使我设置了 --noout 标志,我也会在标准输出上收到错误
xmllint --noout CreDefault.XML
Default.XML:16: parser error : Opening and ending tag mismatch: Networks line 6 and root
orrectiveActions/><fallback/></ErrorHandler></C></T><Vars/></G></Generic></ro ot>
^
Default.XML:16: parser error : Premature end of data in tag root line 1
orrectiveActions/><fallback/></ErrorHandler></C></T><Vars/></G></Generic></ro ot>
Run Code Online (Sandbox Code Playgroud)
是否可以将命令配置为静默模式?所以我可以检查$?仅有的?
我需要的是:
xmllint --noout CreDefault.XML
echo $?
1
Run Code Online (Sandbox Code Playgroud)
我没有看到任何方法可以让xmllint自己保持沉默,这意味着如果您真的不想看到错误输出,您只需自己将其重定向即可。
xmllint --noout CreDefault.XML 2>/dev/null
Run Code Online (Sandbox Code Playgroud)
(注释中的讨论表明这在 shell 中不起作用(t)csh。)
| 归档时间: |
|
| 查看次数: |
6243 次 |
| 最近记录: |