0

I have elasticsearch curl command which I have placed in one shell script as follows:

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

Now it is supposed to show output only as Total mtaLogs count is <some count>

But it is showing output as

  % 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

Why am I getting this unnecessary table output on console?

Any help here?

1 Answer 1

2

You simply need to add the -s or -silent switch to the curl command and it will be executed silently without the verbose table, i.e.

totalCount=`curl -s -XGET 'http://localhost:9200/_all/_count?pretty=true' -d '{
                  ^
                  |
                  |
                 HERE
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks.. it helped... :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.