Can I use wget to check , but not download

后端 未结 5 422
失恋的感觉
失恋的感觉 2021-01-30 04:53

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

5条回答
  •  囚心锁ツ
    2021-01-30 05:31

    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.

提交回复
热议问题