3

I am trying to zip a directory, but I have a list of specific files that I need to ignore. This list is generated with a script and is quite long so when I pass them to the zip command I get an error saying that the command line is too long.

I basically need the functionality asked in this question - Argument list too long when zipping large list of certain files in a folder - but for the -x option to ignore the files instead of add them.

These files are in various subdirectories and don't follow a specific naming convention so there is no clear pattern to ignore them without specifying them all individually.

Is there any way to do this?

1 Answer 1

3

You can (as suggested in the manpage) put your list into a file, rather than using positional parameters for the list:

   -x files
   --exclude files
          Explicitly exclude the specified files, as in:

                 zip -r foo foo -x \*.o

          which  will include the contents of foo in foo.zip while exclud‐
          ing all the files that end in  .o.   The  backslash  avoids  the
          shell  filename  substitution, so that the name matching is per‐
          formed by zip at all directory levels.

          Also possible:

                 zip -r foo foo [email protected]

          which will include the contents of foo in foo.zip while  exclud‐
          ing   all  the  files  that  match  the  patterns  in  the  file
          exclude.lst.

You must log in to answer this question.

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