0

I would like to extract a single file from a tar.gz file, but its in another folder than I am currently in. Is it possible to extract from "distance"?

1 Answer 1

2

I did not get if you want the file extracted to current working directory or the remote directory, but if you want the file in the current working directory, you can just run:

tar xzf /path/to/archive.tar.gz file-to-extract

and file-to-extract will be extracted in the current working directory

Edit:

If you want to place the file in another folder, use the -C option

tar xzf /path/to/archive.tar.gz -C /path/to/target/directory file-to-extract
5
  • 1
    I think you mean tar zxf /path/archive.tar.gz .... since it is a gzipped file and not just a tar archive.
    – mdpc
    Nov 1, 2014 at 21:59
  • Its in that remote directory I would like to extract. Nov 1, 2014 at 22:15
  • To my own defense, my experience is that you don't have to use the -z option when extracting files, only when creating archives. Maybe this only applies to specific version of tar? Nov 1, 2014 at 22:22
  • @StianHvatum If I do that I get gzip: stdin: unexpected end of line. Nov 1, 2014 at 22:57
  • If you omit the z-option, or if you use the C-option?? Nov 1, 2014 at 23:02

You must log in to answer this question.

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