I would like to verify if a URL exists without downloading. I am using below with curl:
if [[ $(curl ftp://ftp.somewhere.com/bigfile.gz) ]] 2>/dev/null;
then
echo "This page exists."
else
echo "This page does not exist."
fi
or using wget:
if [[ $(wget ftp://ftp.somewhere.com/bigfile.gz) -O-]] 2>/dev/null;
then
echo "This page exists."
else
echo "This page does not exist."
fi
This works great if the URL doesn't exist. If it exists, it downloads the file. In my case, the files are really big and I do not want it to download. I just want to know if that URL exists.