保留文件结构的同时在当前目录中解压缩 [英] unzip in current directory while preserving file structure

查看:48
本文介绍了保留文件结构的同时在当前目录中解压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在目录中,并且有一个包含文件和目录的zip文件.我需要将该文件解压缩到当前目录中,但要保留文件结构.

I'm in a directory and I have a zip containing files and directories. I need to unzip that file, into current directory, but preserving the file structure.

unzip myfile.zip将在当前目录中创建一个myfile目录,这不是我想要的.

unzip myfile.zip will create a myfile directory in current directory which is not what I want.

unzip -j myfile.zip将杀死所有文件结构,这不是我想要的.

unzip -j myfile.zip will kill all the file strucure, which is not what I want.

推荐答案

unzip myfile.zip 通过保留zip文件中的路径名来提取工作目录中的文件.

unzip myfile.zip extracts files in the working directory by keeping path names from the zip file.

因此,如果获得子目录 myfile ,则表示它是压缩文件相对路径的一部分.通过列出zip内容进行检查

So if you get a subdirectory myfile it means it is part of the relative path of compressed files. Check it by listing the zip content

unzip -l myfile.zip

因此,您可以从上面的目录解压缩文件,或者使用 -d 选项从目标目录解压缩,其中-d是上面的目录

So you can unzip the file from the directory above, or, from the target directory unzip with -d option, where -d is the directory above

cd myfile
unzip myfile.zip -d ..

这篇关于保留文件结构的同时在当前目录中解压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆