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.

How do I gunzip to a destination directory other than the current one?

This did not work:

gunzip *.gz /putthemhere/
share|improve this question

2 Answers 2

up vote 27 down vote accepted

Ask gunzip to output to standard output and redirect to a file in that directory:

gunzip -c file.gz > /THERE/file

zcat is a shortcut for gunzip -c.

If you want to gunzip multiple files iterate over all files:

for f in *.gz; do
  STEM=$(basename "${f}" .gz)
  gunzip -c "${f}" > /THERE/"${STEM}"

(here basename is used to get the part of the filename without the extension)

share|improve this answer
where .pdf should be .gz –  Noah Jul 25 '12 at 19:53
@Noah: Good catch, fixed. –  Benjamin Bannier Jul 25 '12 at 20:56
Creates the file, but does not preserve file ownership, permissions etc. That may be good or bad depending on your precise situation. –  Chris Johnson Nov 9 '14 at 17:12

You can try with > to redirect the result to the place you want.

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.