Skip to content

Instantly share code, notes, and snippets.

@anujkaushal
Created May 11, 2020 06:47
Show Gist options
  • Save anujkaushal/0328db67a2f8673315b9f71ed36966ed to your computer and use it in GitHub Desktop.
Save anujkaushal/0328db67a2f8673315b9f71ed36966ed to your computer and use it in GitHub Desktop.
Check response code of URLs using input file
#!/bin/bash
input="./urls.txt" # input file for list of URLs
output="./result.txt" # output file
echo "ResponseCode, URL" > $output
while IFS= read -r line
do
status_code=$(curl --write-out %{http_code} --silent --output /dev/null $line)
outputStr=$(echo "$status_code, $line")
echo $outputStr
echo $outputStr >> $output
done < "$input"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment