bash: get http response codes for a list of URLs

I had a file with a list of URLs, and I wanted to grab the HTTP response codes for each of them. I’m sure this quick bash script isn’t the best way to do it, but it works, and I’ll probably want to do this again someday, so here it is!


while read line    
    echo $(curl --write-out %{http_code} --silent --output /dev/null $line)
done <$1