General Computing
linux compression tar
Updated Wed, 18 May 2022 04:49:49 GMT

Compress over 180k files

I am not even close to an expert in the infrastructure matter but I am trying to lend a hand to someone who's even worse than I am in this matter.

We need to compress 184k specific files into a tar.gz but we don't know how to do it and, through the posts we found, instructs how to compress only through pattern.

The command that we know is the basic one, tar -czvf filename.tar.gz files, but I can't imagine it for a list of specific files, I believe that I'll need a script for it or something similar.

We have a file that contains all the file paths that we need already. I thought of compressing the entire folder as well, but there are over 1 million files in there, so, there is no how to use this approach.

Can someone point me the way that I should follow in order to achieve this?



We have a file that contains all the file paths that we need already

Investigate --files-from option of tar; man 1 tar says:

-T, --files-from=FILE
get names to extract or create from FILE

Your basic command will become something like

tar -czvf filename.tar.gz -T mylist.txt

Similar question on Stack Overflow.

Comments (2)

  • +0 – This was quick! Thank you very much, it is precisely what I needed. I guess I didn't find the answer since I didn't know which terms to use :$ — Apr 24, 2018 at 08:27  
  • +1 – @Banns general rule of thumb is to run the command with --help or -h to see what parameters it supports. Otherwise man tar should show you the manual page for the program where there might be more descriptive usage examples. — Apr 24, 2018 at 08:35  

External Links

External links referenced by this document: