Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.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
Shell 可以从";xml“grep--count”;排成一行?_Shell_Grep - Fatal编程技术网

Shell 可以从";xml“grep--count”;排成一行?

Shell 可以从";xml“grep--count”;排成一行?,shell,grep,Shell,Grep,这可能是一个愚蠢的问题,但我希望从下面的xml_grep语句中得到值“64”,但它比我需要的更详细。我没有看到只获取数字计数的选项——我不希望路径源返回。这有什么诀窍吗,或者我需要通过countItems变量中的某个方法尝试获取“total:”之后显示的任何数字吗?任何提示,谢谢 $ countItems=`xml_grep --count //item http://10.0.123.456:8890/some/pagexml.htm` $ echo $countItems http://1

这可能是一个愚蠢的问题,但我希望从下面的xml_grep语句中得到值“64”,但它比我需要的更详细。我没有看到只获取数字计数的选项——我不希望路径源返回。这有什么诀窍吗,或者我需要通过countItems变量中的某个方法尝试获取“total:”之后显示的任何数字吗?任何提示,谢谢

$ countItems=`xml_grep --count //item http://10.0.123.456:8890/some/pagexml.htm`
$ echo $countItems 
http://10.0.123.456:8890/some/pagexml.htm: 64 total: 64

我无法评论
xml\u grep
命令可能的“修复”,但一个(相对)简单的方法可以满足您的需要:

$ countItems="${countItems##*: }"   # throw away everything up to the last ":" + "<space>"
$ echo "${countItems}"
64
$countItems=“${countItems###*:}”#扔掉所有东西直到最后一个”:“+”
$echo“${countItems}”
64
注意:假设
xml\u grep
输出总是以