Search code examples
linuxunixcompressiontarbzip2

bzip2 on certain files within directory


I have a bzipped folder that contains files within it. The files within it are about 1TB, but I only need about 50GB of them, and if I try to get all the files in the folder, my machine runs out of memory. Here is the command I'm currently using:

pbzip2 -dvc -m1000 popularity20151223.tbz |sudo tar x

How would I only extract the file called "myfile" from the above tarball? The equivalent of this with tar is:

tar xpj -C {tarball} {files_to_unarchive}

Solution

  • You can do this similarly with the tar command:

    pbzip2 -dcv -m1000 /Users/david/Desktop/popularity20151216.tbz
      | tar x popularity20151216/myfile1  popularity20151216/myfile2