压缩而不创建父文件夹

III*_*III 5 linux zip

我有一个这样的文件夹结构:

- project:
-- folder 01:
--- file1.cpp
--- file2.cpp
-- folder 02:
--- file1.cpp
--- file2.cpp
Run Code Online (Sandbox Code Playgroud)

我想以我得到(当我解压缩)这个结构的方式压缩项目文件夹的内容:

- folder 01:
-- file1.cpp
-- file2.cpp
- folder 02:
-- file1.cpp
-- file2.cpp
Run Code Online (Sandbox Code Playgroud)

我的问题是现在我总是得到一个与我的 zip 文件同名的父文件夹,其中包含文件夹 01 和 02。有没有办法在不获取这个父文件夹的情况下进行压缩?

小智 2

zip -r foo ./

假设 **

./

** 即,当前工作目录是您案例中的项目。

-r 用于递归压缩

foo 是您的 zip 文件的名称,即 foo.zip 是您想要的最终压缩产品。