brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wget --spider checks that a URL exists without downloading it

CLI
~/tips/tip-wget-spider-check-links

wget --spider https://example.com/file.zip

Check if a URL or a list of links still works, without fetching the content.

Before I put a link in a script or a note, I want to know if it still works. Downloading the whole file just to find out is wasteful.

With --spider, wget behaves like a web spider: it doesn’t download the pages, it only checks that they are there.

wget --spider https://example.com/file.zip

The exit status tells the result (0 when the file exists, 8 when the server answers with an error such as a 404), so it fits in a shell condition. The manual even shows it checking a list of links from a bookmarks file:

wget --spider --force-html -i bookmarks.html

A caveat: the manual itself says this feature needs much more work to get close to real web spiders. A server that answers differently to this kind of request can give a false result, so treat a failure as a reason to look, not as proof.

Further reading: wget man page (Debian)

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' yt-dlp --download-archive archive.txt "https://www.youtube.com/playlist?list=PLAYLIST_ID" All CLI tips (46) All topics

Link