zip selected directories recursively in linux

6

1

I would like to zip only selected directories(and its child directories as well)

I have many directories in the current folder like app, content, db, library etc.

But I would like the zip only app and content and its child folders. I am trying the following.

zip -r ../backups/code/20110625 -i app/* -i content/* . *

But I am getting the following error.

zip error: Invalid command arguments (nothing to select from)

What is the correct syntax to achieve this?

Lenin Raj Rajasekaran

Posted 2011-06-25T10:08:38.680

Reputation: 423

Answers

12

Try:

zip -r myzipfile.zip ../backups/code/20110625 app/* content/* . *

You need to put the name of the zipfile first.

slotishtype

Posted 2011-06-25T10:08:38.680

Reputation: 2 875

Thanks. I need to remove the leading slash from app and content to make it work. – Lenin Raj Rajasekaran – 2011-06-25T10:25:32.317

@emaillenin No probs. I made the change, even though it is context specific. Will you accept the answer please? Glad it worked for you. – slotishtype – 2011-06-25T10:28:36.510