Skip to content

Instantly share code, notes, and snippets.

@GeorgeTsiokos
Created January 8, 2023 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeorgeTsiokos/058b58eea604d8e3ce2b8a9321fd922c to your computer and use it in GitHub Desktop.
Save GeorgeTsiokos/058b58eea604d8e3ce2b8a9321fd922c to your computer and use it in GitHub Desktop.
curl 7.68 download with eTag support
# ======================
# curl-download.sh v1.0
# filename
# url
# ======================
if [ -f "$1.etag" ]; then
HTTPCODE=$(curl --etag-compare $1.etag --url $2 -o $1 -sw '%{http_code}' --retry 9)
if [ "$HTTPCODE" = "304" ]; then
echo "$1: not modified"
exit 0
fi
echo "$1: modified"
else
echo "$1: 1st download"
fi
curl --etag-save $1.etag --url $2 -o $1 --no-progress-meter --retry 9 --dump-header $1.header
cat $1.header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment