Zip gives error "-bash: /usr/bin/zip: Argument list too long"
my zip program gives me the error
"-bash: /usr/bin/zip: Argument list too long"
When there are more than 3100 files in a directory.
working fine when the files are <3100,
I know there is no limit for the files in the zip,
Am not sure why i am getting this error.File name are having aroung 46 char long.
Is there a limit to files or file names for zip program?
zip -r -q -j abc.zip *.pdf
Any assistance would be highly appreciated
Thanks in Advance
The restriction is the lenght of the parameter list in the shell; not specific to any program. I'm sure an 'ls *.pdf' gives the same result.
The shell attempts to find all the *.pdf files and pass them as arguments to ls. It's the length of the filenames and the number that exceeds the arg limit, not just the 3100 files.
The code below uses find which does not do the expansion, but checks the files one at a time. Passing the results to zip.
Zip is not the problem, bash is.
Command line expansion comes before the zip command, so *.pdf is expanded first and then zip is given the files. The expansion of *.pdf generates the error.
To my knowledge the argument list can only be X files long, X depending on platform, hardware, OS etc.
You could use find and pipe to zip.
Hope this helps.
There is a limit in bash on how much memory the command line arguments can occupy.
You might try using find and xargs instead.
find ./ -iname "*.pdf" | xargs -l 1000 zip -r -q -j abc.zip
The xargs program will take the stdout from the "|" pipe and use them for the command line arguments. The -l "el" option limits the number of lines expanded at a time.
You might consider using tar instead, unless you are zipping the files for windows users.
See "man find", "man xargs" and "man tar" for more details.
|All times are GMT -5. The time now is 11:23 AM.|