在shell中使用zip命令压缩文件,如何做到不创建新的文件夹

使用命令:zip -qr file.zip ./dist ,打包后解压zip文件,发现自动创建了file文件夹。
有尝试加入 -j 参数,发现打包错误,因为子文件夹中有重名文件。

请问如何做到打包后不自动创建文件夹呢

阅读 8k
2 个回答
cd dist/ && zip a.zip * && mv a.zip ../ && cd ../

懂你的意思,不想打包的压缩文件里有文件夹哈哈哈哈。

我使用 zipunzip 作为测试,但没有发现你说的情况。

[root@localhost ~]# ls dist/
hello
[root@localhost ~]# zip -qr file.zip ./dist
[root@localhost ~]# ls
dist  file.zip

[root@localhost ~]# unzip file.zip -f
Archive:  file.zip
[root@localhost ~]# ls
dist  file.zip
[root@localhost ~]# ls dist/
hello
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进