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?


1 Answer 1


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.

  • 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 :$
    – Banns
    Apr 24, 2018 at 8: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.
    – Mokubai
    Apr 24, 2018 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.