Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to zip files from a directory but only to a given depth. In the example below I would like to include files until a depth of 3:

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

If I could issue:

zip --depth 3 -r output dir0

I would have the following output:

dir0/dir1/file1

How can I achieve this? Should I use tar, or is there any other common tool in Linux?

share|improve this question

1 Answer 1

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 -@ ...
share|improve this answer
    
Thanks, that is indeed the solution. –  Gadolin Oct 18 '10 at 21:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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