[Bash] Shell Script to List URLs That Return HTTP Status Code 200
I’ll introduce a shell script that runs on bash to list URLs that return HTTP status code 200.
array=();
for (( i = 1 ; i < 10 ; i++ ))
do
  url=http://example.com/$i/;
  http_code=`curl -LI $url -o /dev/null -w '%{http_code}' -s`;
  if [ $http_code = 200 ]; then
    array+=($url);
  fi
done
for el in $array; do
  echo $el;
done
This is useful when you want to quickly check URLs.
That’s all from the Gemba.