Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I frequently use wget to download tarballs and zip files from the web, then either untar then or gunzip them. I do:


Is there a way for me to automatically pass the zip file to tar or unzip WHILE wget-ting? In pseudocode:

wget && unzip
share|improve this question
up vote 7 down vote accepted

You could avoid using intermediary files and the problem would disappear

wget -O - | funzip
share|improve this answer
So this will work despite not giving unzip the file name of the document? If so, +1 and accepted. Nice and clean. – n0pe Jun 9 '11 at 14:41
Yeah, note the difference between unzip which acts on files and funzip which acts on stdin. – slhck Jun 9 '11 at 14:43
ahhh yeah I didn't see that. Many thanks! – n0pe Jun 9 '11 at 14:47
@MaxMackie yes, the -O - means 'output to stdout'. There is no file, no document. There's just a pipe directly to funzip which will extract to the CWD. – Rich Homolka Jun 9 '11 at 14:47
I do rather like this one better than my answer. I've never run across funzip before! Thanks! – Kirk Jun 9 '11 at 14:56
MYFILE=filename; wget${MYFILE} && unzip ${MYFILE} && rm -f ${MYFILE}
share|improve this answer

Both answers here work, and @RedGrittyBrick 's answer eliminates the temp file that you delete anyway (I'd accept his). I'll add another way.

You can do string manipulation on the variables you use for the URL to get the output file.
wget $URL
FILE=${URL##*/} # strip everything up to last /
unzip $FILE
rm -f $FILE
share|improve this answer
I think you mean "everything up to last /"? – slhck Jun 9 '11 at 15:09
@slhck good point, I changed to be last /, in both comment and code. Thanks – Rich Homolka Jun 9 '11 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .