unix bsd
tar
and gz
formats very popular in Linux, Unix and BSD world. A lot of files like source code, backup, configuration files etc. are compressed with this two formats. As a Linux system administrator we generally face with tar.gz
extension files. In this tutorial we will look how to extract them easily.
tar
和gz
格式在Linux,Unix和BSD世界中非常流行。 这两种格式压缩了很多文件,如源代码,备份,配置文件等。 作为Linux系统管理员,我们通常会面对tar.gz
扩展文件。 在本教程中,我们将研究如何轻松提取它们。
柏油 (Tar)
Tar is very old and popular format used to put separate file and directories into single file. This is most used technique before compression. Detailed tutorial about tar
command be found in the following link.
Tar是非常古老且流行的格式,用于将单独的文件和目录放入单个文件中。 这是压缩前最常用的技术。 以下链接提供了有关tar
命令的详细教程。
http://www.poftut.com/how-to-uncompress-and-untar-tar-gz-file-in-linux-unix-and-bsd/
http://www.poftut.com/how-to-uncompress-and-untar-tar-gz-file-in-linux-unix-and-bsd/
z (Gz)
Gz is the gzip format which is provided by all of the Linux, Unix and BSD files systems. gz
command is used to compress, extract and list files and directories.
Gz是所有Linux,Unix和BSD文件系统提供的gzip格式。 gz
命令用于压缩,提取和列出文件和目录。
列出文件和目录 (List Files and Directories)
Before extracting or uncompressing the tar.gz
file we generally need to list file and directories in the archive. We will use tar
command with -tvf
option to list them. In this example we will list contents of rarlinux-x64-5.4.0.tar.gz
在提取或解压缩tar.gz
文件之前,我们通常需要在归档文件中列出文件和目录。 我们将使用带有-tvf
选项的tar
命令列出它们。 在此示例中,我们将列出rarlinux-x64-5.4.0.tar.gz
内容
$ tar -tvf rarlinux-x64-5.4.0.tar.gz
提取整个Tar.gz存档(Extract Entire Tar.gz Archive)
The most used operation is extracting entire archive. This will extract all file into new directory. We will use tar
command with -xvf
option. In this example we will extract all content of the rarlinux-x64-5.4.0.tar.gz
最常用的操作是提取整个存档。 这会将所有文件提取到新目录中。 我们将使用带有-xvf
选项的tar
命令。 在此示例中,我们将提取rarlinux-x64-5.4.0.tar.gz
所有内容
$ tar -xvf rarlinux-x64-5.4.0.tar.gz
提取单个文件(Extract Single File)
Another useful example is extracting single file from the tar.gz
archive. We will specify the file or directory we want to extract after the archive name. In this example we will extract file rar/rar.txt
from archive.
另一个有用的示例是从tar.gz
存档中提取单个文件。 我们将在存档名称之后指定要提取的文件或目录。 在此示例中,我们将从存档中提取文件rar/rar.txt
。
$ tar -xvf rarlinux-x64-5.4.0.tar.gz rar/rar.txt
提取多个文件 (Extract Multiple Files)
We can also extract multiple files without extracting the whole archive we will add all files and directories we want to extract one by by. In this example we want to extract rar/rar.txt
and rar/license.txt
from the archive.
我们也可以提取多个文件而无需提取整个档案,我们将添加我们要提取的所有文件和目录。 在此示例中,我们要从存档中提取rar/rar.txt
和rar/license.txt
。
$ tar -xvf rarlinux-x64-5.4.0.tar.gz rar/rar.txt rar/license.txt
翻译自: https://www.poftut.com/how-to-uncompress-and-untar-tar-gz-file-in-linux-unix-and-bsd/
unix bsd