我有elasticsearch curl命令,我将其放在一个shell脚本中,如下所示:
#!/bin/bash
totalCount=`curl -XGET 'http://localhost:9200/_all/_count?pretty=true' -d '{
"query" : {
"bool" : {
"must" : [
{
"match" : {
"type" : "mtaLogs"
}} ,
{
"filtered" : {
"filter" : {
"range" : {
"@timestamp" : {
"from" : "2015-07-27T00:00:01",
"to" : "2015-07-27T23:59:59"
}
}
}
}
}
]
}
}
}' | jq '.count'`
echo "Total mtaLogs count is $totalCount"
现在它应该只显示输出Total mtaLogs count is <some count>
但它显示输出为
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 98 0 98 0 755 7572 58337 --:--:-- --:--:-- --:--:-- 0
Total mtaLogs count is 39
为什么我在控制台上获得这个不必要的表输出?
这里有任何帮助吗?
答案 0 :(得分:2)
您只需要将-s
或-silent
开关添加到curl命令,它将在没有详细表的情况下静默执行,即
totalCount=`curl -s -XGET 'http://localhost:9200/_all/_count?pretty=true' -d '{
^
|
|
HERE