Skip to content

Instantly share code, notes, and snippets.

@jcayzac
Created July 4, 2013 07:29
Show Gist options
  • Select an option

  • Save jcayzac/5925627 to your computer and use it in GitHub Desktop.

Select an option

Save jcayzac/5925627 to your computer and use it in GitHub Desktop.
super-simple http download in bash
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
[ "${1%%:*}" == "http" ]
url="${1##*://}"
host="${url%%/*}"
path="${url#*/}"
exec 3<>/dev/tcp/${host}/80
printf "GET /%s HTTP/1.1\r\nhost: %s\r\nConnection: close\r\n\r\n" "$path" "$host" >&3
cat <&3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment