Created
July 4, 2013 07:29
-
-
Save jcayzac/5925627 to your computer and use it in GitHub Desktop.
super-simple http download in bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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