0

I have been trying to extract a file from a tgz archive for hours.

Using tar -xzf my.tgz ./file.sh extract the file properly. However, an installation script I am using is extracting the file differently, using tar xfzO my.tgz ./file.sh > /tmp/file.sh.

In the first case, tar complete correctly, extracting the file as intended. In the second case however, it output a message informing me that ./file.sh was not found in the archive. Strangely, tar --list ./file.sh -f my.tgz output that the file doesn't exist, but then why is it successfully extracted the first time ?

How can I extract my file, using the second method properly ? Why is tar not finding it, despite it being there ?

2
  • What happens if you remove the preceding ./?
    – undercat
    Commented Aug 16, 2018 at 15:35
  • 2
    Did you try to use a correct command line? Your command line tells a correct TAR to open zO as archive.
    – schily
    Commented Aug 16, 2018 at 16:06

1 Answer 1

1

The order of commands to tar is significant. Specifically: the argument directly after the f must be the tar-archive. Try:

tar xzOf my.tgz ./file.sh > /tmp/file.sh

You must log in to answer this question.

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