简体   繁体   中英

linux : how to compress each file individually in an archive tar/cpio/…other

I'm searching how to make an archive with each file into it compressed.

For example : fic1.txt fic2.log fic3.srt

I want to make an archive "fics.tar" with each file individually compressed into it, and files renamed.

The archive should contain : fic1.txt.gz fic2.log.gz fic3.srt.gz

Problem with tar/pax/cpio programs is that we can't do this directly, and i don't want to compress the files (or copies of them) on the hard drive , it has to be done in memory with a buffer in order to use it with pipes.

example on serverX : ./compress_and_tar fic1.txt fic2.log fic3.srt | ssh server1 "tar -x"

Result : fic1.txt.gz fic2.log.gz fic3.srt.gz on server1 , only hard drive readings on the serverX, zero writings.

Have you an idea ? Thanks

Use a better suited archive type. Either zip (more portable) or 7z (better compression). These formats always compress each member separately.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM