简体   繁体   English

如何使用zip在linux中递归压缩所有txt文件?

[英]How to zip all txt files recursively in linux using zip?

I want to zip all .txt files in using zip command in linux recursively.我想在linux中使用zip命令递归zip所有.txt文件。 For this, I'm using:为此,我正在使用:

zip -r /home/folder/zipName /home/folder2/subfolder1/*.txt

and it is giving me the below error:它给了我以下错误:

zip warning: missing end signature--probably not a zip file (did you
zip warning: remember to use binary mode when you transferred it?)
zip warning: (if you are trying to read a damaged archive try -F)
zip error: Zip file structure invalid

use

zip -r /home/folder/zipName /home/folder2/subfolder1 -i \*.txt

it will do what you expected.它会做你所期望的。

这对我有用...

zip -r /home/folder/zipName /home/folder2/subfolder1/**/*.txt

I had the same error, and I found that the solution was to make sure that your zipName ends in .zip .我遇到了同样的错误,我发现解决方案是确保您的zipName.zip结尾。 Putting this here in case it can help somebody else.把它放在这里以防它可以帮助其他人。

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

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