Ways to download a file via HTTP from the command line

‹ Shaing your home directory between Mac OSX and a VMware Fusion 7 Linux Virtual machine | Dockerfile library ›

Current Ubuntu distributions do not come with either wget or curl installed, but they do include Python and Perl. Here are some alternative ways to download a file and print it on stdout without wget or curl:

  • curl -L http://example.com/file.tar.gz
  • wget -O- http://example.com/file.tar.gz
  • python3 -c "import sys,urllib.request as r;sys.stdout.buffer.write(r.urlopen('http://example.com/file.tar.gz').read())"
  • python2 -c "import sys,urllib as u;sys.stdout.write(u.urlopen('http://example.com/file.tar.gz').read())" 
Subscribe to All Posts - Wesley Tanaka