Can I use wget to check , but not download

mike628 picture mike628 · Jun 7, 2011 · Viewed 100.7k times · Source

Can I use wget to check for a 404 and not actually download the resource? If so how? Thanks

Answer

Shadikka picture Shadikka · Jun 7, 2011

There is the command line parameter --spider exactly for this. In this mode, wget does not download the files and its return value is zero if the resource was found and non-zero if it was not found. Try this (in your favorite shell):

wget -q --spider address
echo $?

Or if you want full output, leave the -q off, so just wget --spider address. -nv shows some output, but not as much as the default.