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'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!

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

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
share|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
add comment
sites/ $ ls

Site 1
Site 2
...
Site 100

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

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.

share|improve this answer
add comment

Use find to generate the list:

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

Your Answer

 
discard

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