Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

wget google.com/somefile.zip
unzip somefile.zip
rm somefile.zip

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

wget google.com/somfile.zip && unzip
share|improve this question

3 Answers 3

up vote 7 down vote accepted

You could avoid using intermediary files and the problem would disappear

wget -O - http://example.com/file.zip | 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. –  maxmackie 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! –  maxmackie 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

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
MYFILE=filename; wget google.com/${MYFILE} && unzip ${MYFILE} && rm -f ${MYFILE}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.