I would like to zip files from directory but only to given depth

so e.g. in example below I would like to include files till depth 3

dir0/ dir1/ dir2 -> subdir1, subdir2 dir3 -> file1

if I could issue

zip --depth 3 -r output dir0

I would have with output: dir0/dir1/file1

How can I achieve that, I may use tar, or any other common tool in linux?

link|improve this question
feedback

1 Answer

up vote 5 down vote accepted

Use find with -maxdepth to limit the traversal depth, then use the tool's option to take filenames from stdin, or xargs or command substitution.

find ... -maxdepth 3 ... | zip -@ ...
link|improve this answer
Thanks, that is indeed the solution. – Gadolin Oct 18 '10 at 21:09
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.