Skip to content

Instantly share code, notes, and snippets.

@plepe
Created December 15, 2010 10:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save plepe/741836 to your computer and use it in GitHub Desktop.
Save plepe/741836 to your computer and use it in GitHub Desktop.
This GIST has been moved to a repository: https://github.com/plepe/wgetar

Often you need to download and extract archives from the internet, e.g. to install Drupal modules. Therefore you download the archive, extract it and remove the original archive. Using modern[tm] UNIX pipes you can directly pipe it to tar; therefore you don't need to save and remove the archive.

Example:

user@host> wgetar http://ftp.drupal.org/files/projects/views-7.x-3.5.tar.gz

See the result:

user@host> ls -R
.:
views

./views:
css
D7UPGRADE.txt
documentation-standards.txt
(and so on)
#!/bin/bash
# Downloads an archive from an URL and pipes it to tar for extraction
wget -O - $@ | tar xvzf -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment