7z linux命令行使用,7z命令教程,其中包含在Linux中压缩和提取文件的示例

7z命令教程,其中包含在Linux中压缩和提取文件的示例

7z命令教程,其中包含在Linux中压缩和提取文件的示例

7zip is a popular tool and compression format. 7zip supports a wide range of platforms and operations systems like Windows, Linux, BSD, macOS, etc.

7zip是一种流行的工具和压缩格式。 7zip支持各种平台和操作系统,例如Windows,Linux,BSD,macOS等。

We will use following syntax for 7z command.

我们将对7z命令使用以下语法。

7z [...] [...]

First before starting using the 7z command we can get usage and help information by using -h option. We can see that different options like adding file to archive, benchmark, delete files from archive etc. listed with the -h option output.

首先,在开始使用7z命令之前,我们可以使用-h选项获取使用情况和帮助信息。 我们可以看到-h选项输出列出了不同的选项,例如将文件添加到归档文件,进行基准测试,从归档文件中删除文件等。

$ 7z -h

1c5d1c1e61e688204d4c5e6cd471a0c0.png

7z Command Line Help Information with -h Option

带-h选项的7z命令行帮助信息

Alternatively, we can list usage and help information without providing any option to the 7z command like below.

另外,我们可以列出用法和帮助信息,而无需为7z命令提供任何选项,如下所示。

$ 7z

3e9abc6c33d4d2c4eb9eecd93ebbe326.png

7z Command Line Help Information

7z命令行帮助信息

While using 7z there is two-component as we can see in the syntax. One of them is commands. Commands are used to specify the operations like:

使用7z时,我们可以从语法中看到两个组成部分。 其中之一是命令。 命令用于指定类似的操作:

a : Add files to archive

a :将文件添加到存档

b : Benchmark

b :基准

d : Delete files from archive

d :从存档中删除文件

e : Extract files from archive (without using directory names)

e :从存档中提取文件(不使用目录名)

h : Calculate hash values for files

h :计算文件的哈希值

i : Show information about supported formats

i :显示有关支持的格式的信息

l : List contents of archive

l :列出档案内容

rn : Rename files in archive

rn :重命名存档中的文件

t : Test integrity of archive

t :测试档案的完整性

u : Update files to archive

u :更新文件以存档

x : eXtract files with full paths

x :具有完整路径的eXtract文件

Switches are used to specify some minor options like create SFX archive, compress shared files, set output log level. Here are some of them

开关用于指定一些次要选项,例如创建SFX存档,压缩共享文件,设置输出日志级别。 这里是其中的一些

-- : Stop switches parsing

-- :停止开关解析

-ai[r[-|0]]{@listfile|!wildcard} : Include archives

-ai[r[-|0]]{@listfile|!wildcard} :包括存档

-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives

-ax[r[-|0]]{@listfile|!wildcard} :排除档案

–ao{a|s|t|u} : set Overwrite mode

– ao{a|s|t|u} :设置覆盖模式

-an : disable archive_name field

-an :禁用archive_name字段

7z can compress files and folders. We will use a command to create a new archive. The new archive file name will be mybackup.7z and we will put files named a.out , body.txt and folder cups . Here the

7z可以压缩文件和文件夹。 我们将使用a命令来创建一个新的存档。 新的存档文件名为mybackup.7z ,我们将放置名为a.out , body.txt和文件夹cups文件。 在这里

$ 7z a mybackups.7z a.out body.txt cups

9b447e0906b121e14eb05de26e703872.png

Compress Files and Folders

压缩文件和文件夹

Here while starting 7z applications show some information about the 7z application like build number, version, developer. And then provided files and folders are scanned and the scan result is printed like 56 folders, 1550 files, and a total 142 MB. After compression is completed new archive size is printed as 96 MB.

在启动7z应用程序时,此处显示有关7z应用程序的一些信息,例如内部版本号,版本,开发人员。 然后扫描提供的文件和文件夹,并打印扫描结果,例如56个文件夹,1550个文件和总共142 MB。 压缩完成后,新的存档大小将打印为96 MB。

In previous example we have created the archive file. Some time we need to add new files to the existing archive file. In this situations we will use same a option to add files.

在前面的示例中,我们创建了存档文件。 一段时间后,我们需要将新文件添加到现有存档文件中。 在这种情况下,我们将使用相同a选项来添加文件。

$ 7z a mybackups.7z fruits.txt

692f013338d71d0b6bf22d29e72c4f45.png

Add Files To The Archive

将文件添加到存档

In this operation mybackup.7z archive file already exists. Some information about the file is printed like path, compression type, size, etc. Then a new file is added to the existing archive or compressed file named mybackup.7z .

在此操作中, mybackup.7z存档文件已存在。 打印有关文件的一些信息,例如路径,压缩类型,大小等。然后,将新文件添加到名为mybackup.7z的现有存档或压缩文件中。

LEARN MORE  How To List and Unrar Rar Files In Ubuntu, Debian, Kali, Mint?

了解更多信息如何在Ubuntu,Debian,Kali,Mint中列出和解压缩Rar文件?

Another useful operation is removing one or more files from an existing archive file. We will use d command with the file we want to delete. In this example, we want to remove the file named fruits.txt from the archive file mybackups.7z .

另一项有用的操作是从现有存档文件中删除一个或多个文件。 我们将对要删除的文件使用d命令。 在此示例中,我们要从存档文件mybackups.7z删除名为fruits.txt的文件。

$ 7z d mybackups.7z fruits.txt

5983a60855dd7e6c72051144374edd73.png

Delete Files From Archive

从存档中删除文件

We can extract all files from an archive or compressed file by using x command or option. We will also provide the archive or compressed file. In this example, we will extract the mybackups.7z .

我们可以使用x命令或选项从存档文件或压缩文件中提取所有文件。 我们还将提供存档或压缩文件。 在此示例中,我们将提取mybackups.7z。

$ 7z x mybackups.7z

9920554f4d53079feda4e5a2d832cb51.png

Extract Files

提取文件

As we can see from the screenshot there are some existing files which will be overwritten. There question whether we want to overwrite, skip, rename, etc. We answer this as Always. After extraction, some statistical information like total folder count, file count size, compressed size is printed.

正如我们从屏幕快照中看到的,有一些现有文件将被覆盖。 有人问我们是否要覆盖,跳过,重命名等。我们将其回答为始终。 提取后,将打印一些统计信息,例如文件夹总数,文件计数大小,压缩大小。

We can also list files of an archive with l command. We will list all files of mybackup.7z archive.

我们还可以使用l命令列出档案文件。 我们将列出mybackup.7z存档的所有文件。

$ 7z l mybackups.7z

aa6d5cbd14ec57168206b34a52d95550.png

List Contents of Archive

列出档案内容

In the output, we can see that files and folders are listed. While listing information like date, time, attributes, size, and name are provided.

在输出中,我们可以看到列出了文件和文件夹。 在列出信息时,会提供日期,时间,属性,大小和名称等信息。

翻译自: https://www.poftut.com/7z-command-tutorial-examples-compress-extract-files-linux/

7z命令教程,其中包含在Linux中压缩和提取文件的示例相关教程

linux pwd命令_带有示例Linux pwd命令教程

linux pwd命令_带有示例Linux pwd命令教程 linux pwd命令 Linux pwd command is the acronym of the print working directory . This command is a very old and popular command. This command does do not have a lot of features. But the features it has

linux chage_chage命令教程,以及在Linux中管理用户帐户的示例

linux chage_chage命令教程,以及在Linux中管理用户帐户的示例 linux chage chage is a tool and command used to change user password expiry information in Linux, BSD, Unix systems. With this command we can set password change time, lock status,

最上面的div下面有空隙_最上面的命令教程,以及监视Linux系统指

最上面的div下面有空隙_最上面的命令教程,以及监视Linux系统指标的示例 最上面的div下面有空隙 Atop is a monitoring tool which is mainly developed for command-line usage. It is capable of showing detailed information about the process, memory, d

适用于Linux的Gzip命令教程

适用于Linux的Gzip命令教程 Gzip is actually a file format which is a compressed file. There is also a tool named gzip which is used to compress and decompress files. Gzip is developed in 1992. It use DEFLATE algorithm with LZ77 and Huffman c

ffmpeg命令教程_FFmpeg命令教程

ffmpeg命令教程_FFmpeg命令教程 ffmpeg命令教程 In today’s multimedia world there are a lot of different formats for video and audio. In order to use video and audio we generally need to convert and edit operations. There are different tools

doxygen简明使用教程

doxygen简明使用教程 1。工作环境:ubuntu18.04 2.安装二进制: sudo apt-get install doxygen doxygen-doc doxygen-gui graphviz 一次性二进制全安装上,发现竟然已经安装过了 3。调用该命令雕出gui界面 doxywizard 4。如下设置: 其中:step1选择输出文档的

linux uname命令_Linux Uname命令教程,并带有列出操作系统,内

linux uname命令_Linux Uname命令教程,并带有列出操作系统,内核,机器,处理器体系结构的示例... linux uname命令 uname command is a simple tool that provides information about the kernel, machine, processor, and operating system. There are a lo

Linux环境和基本命令——改变工作目录命令

Linux环境和基本命令——改变工作目录命令 实验目的 掌握Linux一些基本命令的使用方法 熟悉Linux操作环境 实验内容 改变工作目录命令 常用方法:cd [directories] 若不指定目录,则默认切换到用户的家目录。 例如: 切换到上级目录:cd … 回到刚离开的目录

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值