How to output first line of curl result in a file with bash script
Assuming urls.csv
is just a simple list of URLs and you're working on a linux system (or any system which has /dev/null
), following command will send HEAD requests to each URL and output them next to HTTP response codes.
sed 's/^/url = /; s/\r\?$/\n-o \/dev\/null/' urls.csv |curl -s -K- -w '%{http_code} %{url_effective}\n' -I >outfile
see curl man page for further information.