我将如何仅使用内置于 windows/java/portable 程序的命令从 CMD 中提取 .GZ 文件

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

How would I extract a .GZ file from CMD using only commands built in to windows/java/portable program

javabatch-filecommand-promptminecraftgzip

提问by EDG

My team is working with .GZ files and they need some way, ANY WAY, to extract a .GZ from command line. It can be using Java commands (as long as it can be run from CMD). If it can be done with a third party PORTABLE executable that is fine as well, as long as it's free. I don't have much to go on here so I'm giving the most information as I can. Basically in a nutshell:

我的团队正在处理 .GZ 文件,他们需要某种方式,任何方式,从命令行提取 .GZ。它可以使用 Java 命令(只要它可以从 CMD 运行)。如果它可以通过第三方 PORTABLE 可执行文件来完成,那也很好,只要它是免费的。我在这里没有太多要讲的,所以我会尽可能提供最多的信息。基本上简而言之:

  • I need to open .gz files
  • It has to be done through a Batch file (CMD)
  • It cannot use anything that must be installed apart from Java.
  • It can use a portable EXE (toggleable from CMD)
  • 我需要打开 .gz 文件
  • 它必须通过批处理文件 (CMD) 完成
  • 除了 Java 之外,它不能使用任何必须安装的东西。
  • 它可以使用便携式 EXE(可从 CMD 切换)

Thanks a bunch, sorry it is low on information! -Lucas E. Executive Programmer for EDG

非常感谢,抱歉信息太少!-Lucas E. EDG 执行程序员

Side note: This goes along with minecraft, so, I know I can somehow make and extract them since minecraft saves it's log files in .gz format.If the item I need comes with minecraft I can work with that.

旁注:这与我的世界一起出现,所以,我知道我可以以某种方式制作和提取它们,因为我的世界将它的日志文件保存为 .gz 格式。如果我需要的物品随我的世界一起提供,我可以使用它。

回答by infixed

The 7Zip utility can uncompress a gzip file

7Zip 实用程序可以解压缩 gzip 文件

7z.exe x file.gz -so > uncompressed.dat

7z.exe x file.gz -so > uncompressed.dat

7z.exe is portable if you bring its DLLs along (just 7z.dll I think)

7z.exe 是可移植的,如果你带上它的 DLL(我认为只有 7z.dll)

It's free in that you personally can use it without payment. It you want to distribute it with a commercial product you may have to contact the owners.

它是免费的,您个人无需付费即可使用。如果您想将它与商业产品一起分发,您可能必须联系所有者。

I have seen it mentioned by name when included in a 3rd party product. "Powered by 7zip" But the license on the site reads (in part)

我看到它包含在第 3 方产品中时按名称提及。“Powered by 7zip” 但网站上的许可证写着(部分)

7-Zip
  ~~~~~
  License for use and distribution
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  7-Zip Copyright (C) 1999-2016 Igor Pavlov.

  Licenses for files are:

    1) 7z.dll: GNU LGPL + unRAR restriction
    2) All other files:  GNU LGPL

  The GNU LGPL + unRAR restriction means that you must follow both 
  GNU LGPL rules and unRAR restriction rules.


  Note: 
    You can use 7-Zip on any computer, including a computer in a commercial 
    organization. You don't need to register or pay for 7-Zip.

http://7-zip.org/

http://7-zip.org/

回答by Gerco Dries

Java has built-in code for handling gzip streams but it's not accessible from the command line (e.g. you cannot type java -blahand ungz something). If you have access to the Java compiler you can write a small program to ungz your file.

Java 具有用于处理 gzip 流的内置代码,但无法从命令行访问它(例如,您无法键入java -blah和 ungz 某些内容)。如果您可以访问 Java 编译器,您可以编写一个小程序来对您的文件进行 ungz。

Another option would be to download GNU gzip for Windows(if using Windows) and use the binaries in that package. Any non-windows OS should already have "gunzip" installed, so you wouldn't have to provide anything extra.

另一种选择是下载适用于 Windows 的 GNU gzip(如果使用 Windows)并使用该软件包中的二进制文件。任何非 Windows 操作系统都应该已经安装了“gunzip”,因此您不必提供任何额外的东西。