for name in `cat textfile`; do curl -s -o /dev/null --write-out %{http_code} $name 2>&1 ; echo -e "\n"; done
the explanation:
for url in `cat textfile`
Output all the entries in your text file with the cat
command, and make the current pointer available through the url
variable.
curl -s -o /dev/null --write-out %{http_code} $url 2>&1
Call cURL and suppress any progress status with -s
, write any other output to /dev/null
(it's a black hole which you can throw anything into) with the -o
switch, then use --write out %{http_code}
to give you the return code for each link you do, put the current link down with $url
, and redirect STDERR to STDOUT with 2>&1
(in case you do get any errors). Then...
; echo -e "\n"
Echo on a new line, regardless if the last statement (that whole cURL block) failed.
`; done
Finish the loop.
This probably isn't what you wanted though, since it only prints out the return codes.