Context: AWS documentation on how to create zip files for python code with dependencies, see:

I understand -r is recursion flag, but I'm unclear what the "9" in -r9 achieves?

~/my-function$ cd package ~/my-function/package$ zip -r9 ${OLDPWD}/function.zip . adding: PIL/ (stored 0%) adding: PIL/.libs/ (stored 0%) adding: PIL/.libs/libfreetype-7ce95de6.so.6.16.1 (deflated 65%) adding: PIL/.libs/libjpeg-3fe7dfc0.so.9.3.0 (deflated 72%) adding: PIL/.libs/liblcms2-a6801db4.so.2.0.8 (deflated 67%) ... 

2 Answers

-r9 is a combination of the -r and -9 switches.

The switch -9 means strongest compression, on a scale from 0 to 9.

Type zip for a list of options.

To complement @Zerte's answer, here is the output from zip --help:

 -f freshen: only changed files -u update: only changed or new files -d delete entries in zipfile -m move into zipfile (delete OS files) -r recurse into directories -j junk (don't record) directory names -0 store only -l convert LF to CR LF (-ll CR LF to LF) -1 compress faster -9 compress better -q quiet operation -v verbose operation/print version info -c add one-line comments -z add zipfile comment -@ read names from stdin -o make zipfile as old as latest entry -x exclude the following names -i include only the following names -F fix zipfile (-FF try harder) -D do not add directory entries -A adjust self-extracting exe -J junk zipfile prefix (unzipsfx) -T test zipfile integrity -X eXclude eXtra file attributes -y store symbolic links as the link instead of the referenced file -e encrypt -n don't compress these suffixes -h2 show more help 

As seen above, the -r flag results in recurse into directories

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.