Browse - Computer Tips - Can I use pure bash to download a webpage?
Q. Can I use pure bash to download a webpage?
A. Yes, use /dev/tcp
More on Using Bash's Built-in /dev/tcp File (TCP/IP)
Everything is a file!
Putting together all the comments from that page we get:
[ -z "$PORT" ] && PORT=80
# Connect to server
# Send command to server
echo -en "GET / HTTP/1.1\r\nhost: http://$HOST/$FILE\r\nConnection: close\r\n\r\n" >&3
# Get response
# Close socket
This is cool but I would still recommend wget for a production script
that fetches web pages. For starters, wget follows redirects unlike this