2015-07-28 54 views
0

我有我已放置在一个外壳脚本elasticsearch curl命令如下:怪异输出,同时在外壳脚本中放置elasticsearch curl命令

#!/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 

为什么我在控制台上得到这个不必要的表输出?

这里有什么帮助吗?

回答

2

您只需将-s-silent开关添加到curl命令,它会悄悄地没有冗长的表来执行,即

totalCount=`curl -s -XGET 'http://localhost:9200/_all/_count?pretty=true' -d '{ 
       ^
        | 
        | 
       HERE 
+0

谢谢..它帮助... :) –