Bash 如何在同一zip文件中混合压缩和存储类型的文件

Bash 如何在同一zip文件中混合压缩和存储类型的文件,bash,shell,zipfile,Bash,Shell,Zipfile,我正在寻找一个shell命令(最好是一个单行程序),它将创建一个包含压缩内容和存储内容的zip文件(存储,我指的是官方文档链接1中所述的未压缩内容) 提供了混合不同压缩类型的自由,包括仅存储文件: 4.1.8放入ZIP文件中的每个数据文件可以独立于其他文件的方式进行压缩、存储、加密或数字签名 存档同一ZIP文件中的数据文件 如有必要,可通过IANA注册表中注册的介质类型确认此技术可能性,具体如下: A.本地文件头: 本地文件头签名4个字节(0x04034b50)。。 压缩方法2字节 到目前为止,

我正在寻找一个shell命令(最好是一个单行程序),它将创建一个包含压缩内容和存储内容的zip文件(存储,我指的是官方文档链接1中所述的未压缩内容)

提供了混合不同压缩类型的自由,包括仅存储文件:

4.1.8放入ZIP文件中的每个数据文件可以独立于其他文件的方式进行压缩、存储、加密或数字签名 存档同一ZIP文件中的数据文件

如有必要,可通过IANA注册表中注册的介质类型确认此技术可能性,具体如下:

A.本地文件头:

本地文件头签名4个字节(0x04034b50)。。 压缩方法2字节

到目前为止,我尝试了几个zip参数(
-f-u-u
,…)都没有成功


理想情况下,该命令将压缩文本文件,并存储二进制内容,根据其文件扩展名进行区分(例如:html、css、js将被视为文本,jpg、ico、jar将被视为二进制)。

您是否在寻找
-n
标志

-n suffixes --suffixes suffixes Do not attempt to compress files named with the given suffixes. Such files are simply stored (0% compression) in the output zip file, so that zip doesn't waste its time trying to compress them. The suffixes are separated by either colons or semicolons. For example: zip -rn .Z:.zip:.tiff:.gif:.snd foo foo will copy everything from foo into foo.zip, but will store any files that end in .Z, .zip, .tiff, .gif, or .snd without trying to compress them. -n后缀 --后缀后缀 不要试图压缩使用给定后缀命名的文件。这样的文件很简单 存储(0%压缩)在输出zip文件中,这样zip就不会浪费时间尝试 压缩它们。后缀由冒号或分号分隔。例如: zip-rn.Z:.zip:.tiff:.gif:.snd foo foo foo 将所有内容从foo复制到foo.zip,但将存储以.Z结尾的任何文件, .zip、.tiff、.gif或.snd,而不尝试压缩它们。
除了@cody的答案之外,您还可以使用
-g
-0
按每个文件(组)执行此操作。比如:

zip archive.zip compressme.txt
zip -g archive.zip -0 dontcompressme.jpg

回答得好,谢谢你的帮助<代码>$zip-rn.zip foo foo添加:foo/(存储0%)添加:foo/2.zip(存储0%)添加:foo/1.zip(存储0%)添加:foo/1.txt(缩小78%)添加:foo/2.txt(缩小78%)
-#
(-0, -1, -2, -3, -4, -5, -6, -7, -8, -9)
       Regulate the speed of compression using the specified digit #, where -0
       indicates no compression (store all files), -1 indicates the fastest 
       compression speed (less compression) and -9 indicates the slowest
       compression speed (optimal compression, ignores the suffix list).
       The default compression level is -6.

-g
--grow
       Grow  (append  to) the specified zip archive, instead of creating a new one.
       If this operation fails, zip attempts to restore the archive to its original
       state. If the restoration fails, the archive might become corrupted.
       This option is ignored when there's no existing archive or when at least
       one archive member must be updated or deleted.