我需要从.tar.gzCentOS 服务器上的tarball ( ) 中提取单个文件夹及其子文件夹。我对如何使用 SSH 终端一无所知。
我试过:
gunzip -c files_20100623.0110.tar.gz | tar -xvf home/bsisplas/public_html/staging/template/*.*
Run Code Online (Sandbox Code Playgroud)
但是它似乎无法在存档中找到该文件。此外,gunzip您在语法中的何处指定提取的文件应放在何处?至少可以说,我是 Linux 终端菜鸟。
即使我知道该文件确实是一个 zipgunzip文件,有没有办法创建一个不以 a 结尾.zip的文件?
是否可以对多个文件进行 gunzip 并将它们连接成一个大文件,但在多核机器上并行执行?例如,现在我这样做:
gunzip -c file1.gz > final
gunzip -c file2.gz >> final
gunzip -c file3.gz >> final
gunzip -c file4.gz >> final
Run Code Online (Sandbox Code Playgroud)
我可以做同样的事情,以便不同文件的 gunzip 处理在多核机器的不同 CPU 中完成,并将它们全部连接到同一个最终文件中吗?
可能的重复:
你如何用枪压缩文件并保留 .gz 文件?
我使用以下命令解压缩文件:
gunzip -f test.TGZ
Run Code Online (Sandbox Code Playgroud)
这给了我 test.tar 文件,但我丢失了 test.TGZ 文件。有没有办法保留原始文件?
编辑和更新:我通过 Java 程序调用解压缩命令。TGZ 文件至少包含 1 个图像文件、1 个文本文件和 1 个视频文件。
Java方法:执行命令
private static InputStream executeCommand(String command, File workingDir)
throws Exception {
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(command, null, workingDir);
int exitValue = -1;
try {
exitValue = process.waitFor();
} catch (InterruptedException ignore) {
}
if (exitValue != 0) {
InputStream errStream = process.getErrorStream();
String errMessage = null;
if (errStream.available() > 0) {
byte[] errOutput = new …Run Code Online (Sandbox Code Playgroud) 不知何故,我不小心将扩展名附加.gz到了整个网站目录中的所有文件。

如何撤消此操作?我需要他们保留其原始文件扩展名(例如:picture.jpg.gz-> picture.jpg| file.php.gz-> file.php)。