bash 解压到特定目的地

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8970432/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 21:33:13  来源:igfitidea点击:

Unjar to a specific destination

bashjarterminal

提问by fabricemarcelin

Is there a way to extract a jar file to a specific directory? For instance, I'm in foo directory, which contains the subfolder bar; all my jars files are at the same level at bar. So I passed the command jar xf my.jar -C bar/However when I went to bar folder, the files were not extracted. Is there a way for me to do it without having to move the jar file to bar?

有没有办法将 jar 文件提取到特定目录?例如,我在 foo 目录中,其中包含子文件夹 bar;我所有的 jars 文件都在酒吧的同一级别。所以我通过了命令jar xf my.jar -C bar/但是当我去 bar 文件夹时,文件没有被提取。有没有办法让我不必将jar文件移动到bar?

Thanks

谢谢

回答by dogbane

I don't think jarsupports this, but unzipdoes. Try:

我不认为jar支持这一点,但支持unzip。尝试:

unzip my.jar -d bar

The behaviour is the same as the jarcommand, because jar files are the same as zip files.

行为与jar命令相同,因为 jar 文件与 zip 文件相同。

回答by Pavel Tankov

"Is there a way for me to do it without having to move the jar file to bar?"

“有没有办法让我不必将 jar 文件移动到 bar 中?”

You can do this by entering bar and executing the extract command from there, like this:

您可以通过输入 bar 并从那里执行提取命令来执行此操作,如下所示:

cd bar
jar xf ../my.jar