简体   繁体   English

如何在没有中间文件夹的情况下将文件添加到zip存档

[英]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夹,我想直接在存档的根目录获取文件12

How can i modify the parameters passed to zip command to prevent it from adding files in this archive ? 我如何修改传递给zip命令的参数以防止它在此存档中添加files

Thanks 谢谢

FIXED : 已修正:

Here and Here 这里这里

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.

相关问题 如何在不解压缩的情况下列出 zip 存档中的文件? - How can I list the files in a zip archive without decompressing it? 如何在不解压缩和重新压缩的情况下重命名 zip 存档中的文件? - How to rename files in zip archive without extracting and recompressing them? 创建tar.gz存档并添加所有没有父文件夹的文件和文件夹 - Create tar.gz archive and add all files and folders without parent folder 我们可以将文件名修改后的文件添加到zip存档中吗 - Can we add files to a zip archive with modified file names 如何zip文件夹没有完整路径 - How to zip folder without full path 如何在没有中间文件的情况下区分两个文件的顶行 - How to diff top lines of two files without intermediate file 如何将大文件夹(2.4 GB)归档到多个单独的zip归档文件 - How to archive large folder (2.4 gb) to multiple separated independent zip-archives 如何使用终端在 Linux 中使用只有 .txt 扩展名的文件创建 zip 存档 - How to create zip archive with files with only .txt extension in Linux using terminal 如何在不解压的情况下找到bzip2存档中文件的大小? - How to find sizes of files in bzip2 archive without unpacking? unix unzip:如何批量解压缩文件夹中的zip文件并保存在子文件夹中? - Unix unzip: how to batch unzip zip files in a folder and save in subfolders?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM