我有以下文件:
~/Dir1/file1.txt
~/Dir2/file2.txt
Run Code Online (Sandbox Code Playgroud)
然后我使用以下命令:
cd ~
zip out.zip /Dir1/file1.txt /Dir2/file2.txt
Run Code Online (Sandbox Code Playgroud)
在 out.zip 中,我可以看到两个目录(dir1 和 dir2),但只希望这两个文件(file1.txt 和 file2.txt)位于 out.zip 的根目录中!
我认为该-D选项是我所需要的,但它不起作用。
小智 4
我认为这个-j选项就是你想要的:
zip -j out.zip ~/Dir1/file1.txt ~/Dir2/file2.txt
Run Code Online (Sandbox Code Playgroud)
从手册页:
-j 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 path).
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8791 次 |
| 最近记录: |