curl: tips – silent, using variables in bash


-s=> silent – so no Progress bar

-S=> don’t output errors

bash variables

Using a variable in a curl call within Bash – remember to double-escape quotes. E.g.

curl -X POST -H 'Content-type: application/json' --data "{\"text\": \"${message}\"}"

processing curl output

e.g. I wanted to count the lines from a GET for an Elasticsearch nodes. This seemed the obvious:

curl 0:9200/_cat/indices?v&health=yellow | wc -l

but there are a few things wrong here.

1. it outputted everything to the terminal including all the green nodes and then seemed to hang until I hit Enter – not what I was expecting


there’s an ampersand character in the URL.

2. also there’s progress output from curl


silence with -s

curl -s "0:9200/_cat/indices?v&health=yellow" | wc -l

3. you still get the header from elasticsearch. i.e.

health status index uuid pri rep docs.count docs.deleted store.size



Leave a Reply

Your email address will not be published. Required fields are marked *