2

How to extract one single file from a tar.xz file?

1
  • You can do this graphically with the archive software that was bundled with your distro. Open the tarball in the archive program and the interface will be like using the file manager. Navigate to the file you want, select it, and extract it (usually a menu and/or right-click action).
    – fixer1234
    Jan 3, 2016 at 18:34

2 Answers 2

6

This should work:

tar -xf file.tar.xz "/file/to/extract.png"

See here for some more syntax.

1
  • Is there a way to tell tar to stop after the file was extracted? It seems, it decompresses the whole tar, even though the file asked for was already found... However in our case the tar.bz2 is huge, but the requested file is small and at the beginning of the tar... Jun 21, 2021 at 13:16
0

There are many ways to extract specific or selected files from a tar archive file, but the most used way in Linux using tar options as shown:

tar -tf filename.tar.gz filename

For more examples about tar command can be found at: http://www.tecmint.com/extract-tar-files-to-specific-or-different-directory-in-linux/

1
  • 1
    -t is for TEST, not extract. And I miss the uncompress option (z).
    – Hennes
    Jan 4, 2016 at 10:19

You must log in to answer this question.

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