Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zip -j command, what does the -j option mean?

Wondering what is the -j option mean in the zip command. I found the explanation as following:

-j
Store just the name of a saved file (junk the path), and do not store directory names. By default, zip will store the full path (relative to the current path).

But not quite sure what it is exact mean? Can anyone explain it using the following command as an example?

C:\programs\zip -j myzipfile file1 file2 file3

Thank you.

like image 763
Simon Guo Avatar asked May 17 '10 18:05

Simon Guo


People also ask

What is option in zip?

The options of zip command are: -d : Removes the file from the zip archive. -u : Updates the file in the zip archive. -m : Deletes the original files after zipping. -r : Recursively zips the files in a directory.

What does the zip command do?

zip is used to compress the files to reduce file size and also used as file package utility. zip is available in many operating systems like unix, linux, windows etc. If you have a limited bandwidth between two servers and want to transfer the files faster, then zip the files and transfer.

Does zip delete original file?

By default, the original files don't get deleted even after zip creates a compressed file. However, if you want, you can force the tool to delete original files. This can be done using the -m command line option. This command created files.

Which command is used to zip a file?

Syntax: $zip -u filename. zip file. txt.


2 Answers

This will make more sense with a different example:

C:\programs\zip myzipfile a/file1 b/file2 c/file3

Normally this would result in a zip containing three "subdirs":

a/
+ file1

b/
+ file2

c/
+ file3

With -j, you get:

./
+ file1
+ file2
+ file3
like image 133
Justin R. Avatar answered Sep 19 '22 00:09

Justin R.


in that case it won't do anything special.

but if, for example you type

C:\programs\zip -j myzipfile directory1

and directory1 contains subdirectories, all the files you zip, when extracted, will be put in the same directory, regardless what subdirectory they were in originally.

like image 45
Federico klez Culloca Avatar answered Sep 22 '22 00:09

Federico klez Culloca