How can I unzip a file from another folder?

gunzip -d /home/tomcat_dev/HN/radd/input.txt.gz 

unzips that file to the same folder. But if I want to bring it to my folder? When I do this:

gunzip -d /home/tomcat_dev/HN/radd/o.txt.gz /home/tomcat_dev/ 

it gives me a: gunzip: /home/tomcat_dev/ is a directory -- ignored

migrated from stackoverflow.com Jan 25 '12 at 13:28

This question came from our site for professional and enthusiast programmers.

  • 1
    That's been already answered here. – jcollado Jan 23 '12 at 10:15

It is as simple as below:

gunzip -c filepath.gz > anotherDirectoryPath

More on gunzip, also refer to the man page.



gunzip -c -d /home/tomcat_dev/HN/radd/o.txt.gz > /home/tomcat_dev/o.txt 
  • It works! 10x a lot – radashk RADU Jan 23 '12 at 10:18

Normally I'd use a combination of mkdir and:

gzcat /path/to/somefile.gz >/some/new/path/output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy