How to .zip a selection of files under unix/linux using zip? with directory structures


What I want to do is to be able to .zip a set of files (i.e., *.php), but with directory structures.

If I type this:

zip -r * myZipList

it works perfectly fine, and will save the directory structure.

However, if I do this:
zip -r *.php myZipList

It screws up (pissing me off :() and won't save the directory structure, but instead just
saves/stores everything as being in a 'root' directory.

How do I get the zip functionality to ONLY save/store .php files, AND save the directory structure?

If there is a better place to post this as well, please let me know.

LVL 10
Who is Participating?
ozoConnect With a Mentor Commented:
* or *.php will be expanded by the shell before zip ever sees it
You might want
find . -name "*.php" -print | zip  myZipList -@
zip -r myZipList . -i \*.php
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.