开发者

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

开发者 https://www.devze.com 2022-12-30 08:45 出处:网络
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, z

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 f开发者_开发技巧ull 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.


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.


With the Linux zip command, if you use the -j option with the -i option, the -j may need to be after the -i. Below, the -r means recursive from 'directory1':

   C:\programs\zip -r myzipfile.zip directory1 -i subDirectoryA/*.txt -j

If the -j is earlier in the command, the resulting zip file may be empty.


-j is "Junk pathnames"

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号