Created
February 26, 2019 22:03
-
-
Save atomize/74357b8e5e0b772b1398968eb069bc6c to your computer and use it in GitHub Desktop.
bash function to download file from web without cURL/wget
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
# Add this to your .bashrc | |
# Use it like: you@console_>$ _get https://website.org/file.txt | |
_get () | |
{ | |
IFS=/ read proto z host query <<< "$1" | |
exec 3< /dev/tcp/$host/80 | |
{ | |
echo GET /$query HTTP/1.1 | |
echo connection: close | |
echo host: $host | |
echo | |
} >&3 | |
sed '1,/^$/d' <&3 > $(basename $1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I love that folks are commenting on this gist 4 years later :-D