I've a lot of websites (100+ directories) I want to create a unique zip with only public subdirectory.

My structure now is like:

- Site 1
--- app
--- tmp
--- log
--- public

- Site 2
--- app
--- tmp
--- log
--- public

- ... 100+ dirs ...

Now I need a unique zip and then after unzip it I want to see this structure:

- Site 1
--- public

- Site 2
--- public

- others

Any suggestion how I can do that with linux commands zip/tar ?

Thanks so much!

link|improve this question
2  
I think this is probably a better fit for superuser.com – Zach Johnson Apr 15 '10 at 17:36
feedback

migrated from stackoverflow.com Apr 16 '10 at 1:25

This question came from our site for professional and enthusiast programmers.

4 Answers

Just use wildcards to only specify the public directories:

zip file.zip -r */public
link|improve this answer
+1 yours is a dead simple one-liner – streetpc Apr 15 '10 at 17:36
There is a same version with tar? With zip I've file size limit 4gb. Thanks! – Nino55 Apr 15 '10 at 19:02
Basically I got: zip error: Input file read failure but If I try to zip only the file with error works. – Nino55 Apr 15 '10 at 19:06
feedback
sites/ $ ls

Site 1
Site 2
...
Site 100

$ zip sites.zip * -r -x app tmp log
link|improve this answer
can be quite slow – streetpc Apr 15 '10 at 17:35
feedback

As you have 'tar' tagged. You could try

tar cvjf /path/to/save/at/archive.tar.bz2 . --exclude='*/app' --exclude='*/tmp' --exclude='*/log'

to create a bz2 archive.

link|improve this answer
feedback

Use find to generate the list:

find . -type d -name public -print > list.txt
tar -cvf test.tar -T list.txt
link|improve this answer
Im trying this, I hope with tar there isn't any size limit. – Nino55 Apr 15 '10 at 19:10
feedback

Your Answer

 
or
required, but never shown