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.
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.
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.
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.
Syntax: $zip -u filename. zip file. txt.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With