简体   繁体   English

linux:如何分别压缩tar / cpio /…other中的每个文件

[英]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 例如:fic1.txt fic2.log fic3.srt

I want to make an archive "fics.tar" with each file individually compressed into it, and files renamed. 我想制作一个存档“ fics.tar”,将每个文件分别压缩到其中,并重命名文件。

The archive should contain : fic1.txt.gz fic2.log.gz fic3.srt.gz 存档应包含: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. tar / pax / cpio程序的问题是我们不能直接执行此操作, 并且我不想压缩硬盘上的文件(或它们的副本) ,它必须在内存中使用缓冲区来完成为了与管道一起使用。

example on serverX : ./compress_and_tar fic1.txt fic2.log fic3.srt | serverX上的示例:./compress_and_tar fic1.txt fic2.log fic3.srt | ssh server1 "tar -x" 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. 结果: server1上的fic1.txt.gz fic2.log.gz fic3.srt.gz,serverX上只有硬盘驱动器读数,零写入。

Have you an idea ? 你有主意吗? Thanks 谢谢

Use a better suited archive type. 使用更适合的存档类型。 Either zip (more portable) or 7z (better compression). zip(更便于携带)或7z(更好的压缩)。 These formats always compress each member separately. 这些格式始终会分别压缩每个成员。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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