Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can anyone explain me the below curl command and how it works :

STATUS_CODE=`curl –output /dev/null –silent –head –write-out ‘%{http_code}\n’ $next`
# If you want to set a timeout then add –max-time 15, here 15 is 15seconds
share|improve this question
up vote 2 down vote accepted

You seem to be missing a few double dashes, probably the result of copy and paste:

STATUS_CODE=`curl --output /dev/null --silent --head --write-out ‘%{http_code}\n’ $next`

Assuming that you call this with next being a url (e.g. in a loop or reading from a file):

  • --output /dev/null discards the normal output
  • --silent suppresses the progress meter
  • --head fetch header only
  • --write-out '%{http_code}\n' prints the status code

So in the end the status of the URL request ends up in STATUS_CODE

(And if you want to set the timeout, then use double dashes too: --max-time).

share|improve this answer
Hi Anthon, I have tried the same command but it's returning the error code as "302". what does it mean ?? Also does the curl command work in the same manner for https as it work for http. – user2523599 Jul 2 '13 at 8:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.