Can I use wget to check , but not download

后端 未结 5 421
失恋的感觉
失恋的感觉 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:35

    If you want to check quietly via $? without the hassle of grep'ing wget's output you can use:

    wget -q "http://blah.meh.com/my/path" -O /dev/null
    

    Works even on URLs with just a path but has the disadvantage that something's really downloaded so this is not recommended when checking big files for existence.

提交回复
热议问题