开发者

Zip multiple folders and files depending on filesize in Linux/Ubuntu

开发者 https://www.devze.com 2023-03-25 19:21 出处:网络
I have a directory \"mapnik\" with hundreds of sub-directories, each containing more than 10000 files. I would like to zip \"mapnik\" recursively, preserving the folder-structure but only adding files

I have a directory "mapnik" with hundreds of sub-directories, each containing more than 10000 files. I would like to zip "mapnik" recursively, preserving the folder-structure but only adding files greater than 103 Byte to the archive.

How can I accomplish this? I tried using find and pipes, but with the wrong syntax and the huge number of files, "trial and er开发者_JS百科ror" is not the best way to get it done ;)

Thanks for your help guys!


How about

find -size +103c -print0 | xargs -0 zip -r outname.zip


Delan's suggestion produced some kind of zip-error whith files of the same name. But it got me on the right track. This is what worked for me:

cd mapnik
find . -size +103c -print | zip archive.zip -@
0

精彩评论

暂无评论...
验证码 换一张
取 消