bash - 压缩错误 - 无事可做

标签 bash shell

我尝试压缩给定目录中的所有文件夹。所以我写了这个

find /home/user/rep/tests/data/archive/* -maxdepth 0 -type d -exec zip -r "{}" \;

但是得到了

zip error: Nothing to do! (/home/user/rep/tests/data/archive/tmp.zip)

zip error: Nothing to do! (/home/user/rep/tests/data/archive/tmp_dkjg.zip)

这是内容

user@machine:~$ ls /home/aliashenko/rep/tests/data/archive/
tmp  tmp_dkjg  tmp_dsf

最佳答案

问题是您没有为它将创建的 zip 文件提供名称。

find /home/user/rep/tests/data/archive/* -maxdepth 0 -type d -exec zip -r "{}" "{}" \;

这将为每个子文件夹创建单独的压缩目录 tmp tmp_dkjgtmp_dsf

关于bash - 压缩错误 - 无事可做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40003310/

相关文章:

bash - 在bash脚本中添加两位小数

bash - 使用 && 和 ||在多行 bash 脚本中

unix - 如何使用find命令从列表中查找所有带扩展名的文件?

regex - 使用 GNU sed 在插入或附加行中重用匹配的模式

linux - 如何在 mac OS 中将主机 ip 地址传递给 docker?

bash source 文件末尾有一个退出命令

bash - 从名称获取 AWS EMR 集群 ID

bash - Fish shell中运行脚本的目录

bash - 是否可以使用 xmlstarlet 或其他 bash 工具在 xml 文件内注释/取消注释标签

mongodb - mongo shell 使用外部编辑器编辑查询 : strange chars in Windows