2

I am making a zip of a directory.

I used this command to exclude a certain folder

zip -r myzip.zip /home/test -x share/\*

When I used this command it still scans through that folder. It has numerous subfolders so I don't want it to waste time scanning through everything even though I excluded it. It also throws a lot of zip warning: name not matched because it has numerous symbolic links.

Is there a way to zip without scanning through everything each time?

2
  • The file structure has symbolic links everywhere in that folder. It causes it to loop infinitely when recursively going through that folder. Hence the need to exclude from the scan.
    – jimbob
    Jun 25, 2018 at 19:43
  • "I am making a zip of a directory." Does it have to be zip? Or would you accept "I am making a backup of a directory"? Native tools include tar or pax, and gzip or bzip2. Jun 25, 2018 at 21:01

2 Answers 2

1

From man page:

-y --symlinks

For UNIX and VMS (V8.3 and later), store symbolic links as such in the zip archive, instead of compressing and storing the file referred to by the link. This can avoid multiple copies of files being included in the archive as zip recurses the directory trees and accesses files directly and by links.

0

You will need to include the full path to the directory that you want to exclude. If it is inside of /home/test:

zip -r myzip.zip /home/test -x /home/test/share/\*

If it's elsewhere:

zip -r myzip.zip /home/test -x /home/test/path/to/share/\*

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .