[英]How to add files to zip archive without a intermediate folder
I'm using zip
program in a bash script and i would like to create an archive containing all files in a folder without adding the folder itself to the archive. 我在bash脚本中使用zip
程序,我想创建一个包含文件夹中所有文件的存档,而无需将文件夹本身添加到存档中。
I have such files : 我有这样的文件:
script.sh
files/
files/1
files/2
I'm using this command in script.sh 我在script.sh中使用此命令
zip -q -9 -r arch.zip files/*
but this creates a files
folder in the archive and i would like to get files 1
and 2
directly at the root of the archive. 但这会在存档中创建一个files
夹,我想直接在存档的根目录获取文件1
和2
。
How can i modify the parameters passed to zip
command to prevent it from adding files
in this archive ? 我如何修改传递给zip
命令的参数以防止它在此存档中添加files
?
Thanks 谢谢
FIXED : 已修正:
Obviously, SO search engine is more efficient when the question is posted than before ... 显然,发布问题时,SO搜索引擎比以前更有效...
cd files
zip -q -9 -r ../arch.zip *
you should use -j key. 您应该使用-j键。 Try this way: 尝试这种方式:
zip -q -9 -j arch.zip files/* zip -q -9 -j arch.zip文件/ *
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.