What is the difference between
Obviously, I have googled about it.
Also, I have referred this in quest of finding the difference, but didn't got clarification.
Can anyone from community help me for this?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
From what is likely to be in your man pages:
-r --recurse-paths Travel the directory structure recursively -R --recurse-patterns Travel the directory structure recursively starting at the current directory
zip -r is used when you want to zip files under a specific directory, and
zip -R when you want to zip files under a specific directory and where those files match a pattern defined after the
-R flag, as you can see in the examples provided in that page. Also,
-R starts in the current directory by default.
zip -r foo foo1 foo2 First zips up foo1 and then foo2, going down each directory. zip -R foo "*.c" In this case, all the files matching *.c in the tree starting at the current directory are stored into a zip archive named foo.zip. Note that *.c will match file.c, a/file.c and a/b/.c. More than one pattern can be listed as separate arguments.
Both are recursive, that much you should know, but
-R works with patterns instead of whole trees. For example:
zip -R music "*.mp3"
It will from the current directory match all files ending with
.mp3 and zip them maintaining the structure:
➜ src zip -R amr "*.css" adding: AMR/css/jquery.treeview.css (deflated 76%) adding: AMR/css/importexport.css (deflated 43%) adding: AMR/css/amr_style.css (deflated 82%) adding: AMR/css/backsite.css (deflated 49%) ➜ AMR git:(develop) ✗ zip -R amr "*.css" adding: css/jquery.treeview.css (deflated 76%) adding: css/importexport.css (deflated 43%) adding: css/amr_style.css (deflated 82%) adding: css/backsite.css (deflated 49%)
-r allows this if you use it in conjunction of
zip -r expects a path (a filename works, but defeats the point of adding the
zip -R expects a pattern.
zip -r stuff.zip stuff* will recursively compress all directories whose name begins with
stuff, starting from the current directory. The
* is expanded by the shell to all file/directories that begin with
stuff. If you were to quote the
zip would simply look for a file/directory called
stuff* and compress that file/folder if it existed.
On the other hand,
zip -R stuff.zip "stuff*" will compress all files under the current directory whose names begin with
stuff. Note that the pattern is quoted so that the shell doesn't expand it. If you were to remove the quotes, the shell would expand it before it got to
zip and therefore zip would try to find and compress a file called
If you have a directory called
test in the current working directory that has a file within it called
stuff.txt then this will be added to the zip in the second example as the filename matches the pattern regardless of the name of the containing directory. The file would not be picked up by the first example as it only compresses directories that begin with