bash 如何在不使用bash脚本重新创建所有路径的情况下解压缩到特定目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26212123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to unzip into specific directory without recreate all the path with bash script
提问by Synny
In my ios application, I need to unzip an archive that is placed into /var/mobile/Library/Preferences/xxx into, for example, /var/mobile/Library/Preferences/tmp.
在我的 ios 应用程序中,我需要将放置在 /var/mobile/Library/Preferences/xxx 中的存档解压缩到例如 /var/mobile/Library/Preferences/tmp。
My issue is that when I launch this:
我的问题是,当我启动它时:
unzip /var/mobile/Library/Preferences/xxx/archive.zip -d /var/mobile/Library/Preferences/tmp/
in the tmp folder, there is all the archive path: /var/mobile/Library/Preferences/tmp/var/mobile/Library/Preferences/xxx/archive/...
在 tmp 文件夹中,有所有存档路径:/var/mobile/Library/Preferences/tmp/var/mobile/Library/Preferences/xxx/archive/...
How could I do for only have /var/mobile/Library/Preferences/tmp/archive/... and not all the archive path into the target directory ?
我怎么能只拥有 /var/mobile/Library/Preferences/tmp/archive/... 而不是所有存档路径都进入目标目录?
Thanks in advance
提前致谢
回答by John Zwinck
Try the -j
option to unzip
which flattens the directory structure and writes all the files into the current directory.
尝试-j
以选择unzip
它变平的目录结构及所有文件写入到当前目录。