开发者

GZip on Linux to archive files specified in the text file

开发者 https://www.devze.com 2023-02-12 02:12 出处:网络
I have a text file with paths to the list of files I want to compress into a singe archive. How can I pass this file to GZIP so it can create that archive with a开发者_如何学运维ll files specified in

I have a text file with paths to the list of files I want to compress into a singe archive. How can I pass this file to GZIP so it can create that archive with a开发者_如何学运维ll files specified in the list?

Milan


gzip can only handle a single file at a time. You'll need to archive the files using tar first. Tar can do the compression at the same time (using the "z" argument).

tar cfz archive.tar.gz `cat file`


Well, in the first place, gzip doesn't compress multiple files into a single one, so you'll first tar. At least the GNU tar I checked has the option

  -T, --files-from F
          get names to extract or create from file F

so I suppose tar cfzvT target.tar.gz sourcelist would work.


gzip only compresses a single file. Use:

tar czf target.tar.gz `cat listoffile`
0

精彩评论

暂无评论...
验证码 换一张
取 消