linux - 创建 zip 文件并忽略目录结构

我需要使用以下命令创建一个 zip 文件:

zip /dir/to/file/newZip /data/to/zip/data.txt

这可行,但创建的 zip 文件会创建一个目录结构,该目录结构模仿原始文件的目录。这是很多我不需要的额外文件夹。

粗略浏览一下手册页或 Google 搜索,我都没有找到答案。

最佳答案

你可以使用-j

-j
--junk-paths
          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 directory).

https://stackoverflow.com/questions/9710141/

相关文章:

python - 如何在 Python 中分析内存使用情况?

linux - 有效地测试一个端口是否在 Linux 上打开?

linux - 如何从我的应用程序目录中删除所有 .svn 目录

linux - 从 grep 中排除 .svn 目录

python - 如何在 Python3 中将 'binary string' 转换为普通字符串?

python - 出错时自动启动 python 调试器

python - 如何在类中调用函数?

python - 在 pandas DataFrame 中查找列的值最大的行

linux - 在 Bash 的文件路径参数中获取最后一个目录名/文件名

linux - 如何在bash中将所有子目录中的所有文件gzip到一个压缩文件中