DEV Community


Get http code with wget

eldadak profile image Eldad Assis ใƒป1 min read

Sometimes I don't have curl available for me in a given environment. Some distributions don't provide it with the default installed utilities and I might not have the privileges to install it.
In such cases, I use wget, which is usually installed.

wget --spider -S -T 2 2>&1 | grep "^  HTTP/" | awk '{print $2}' | tail -1

Run wget --help to see details about the parameters I use here.

Discussion (0)

Editor guide