前几日,需要从线上环境拉取部分数据导入到实验库,将工作告知运维后,运维发给我一个
xxx7z.001
xxx7z.002
xxx7z.003
xxx7z.004
看到这个第一眼,不知道怎么处理了,最后运维告知需要使用7za工具处理。为了巩固自己所学,下面开始研究下这个软件工具。
7-zip以高压缩率著称,并且是一款免费开源的压缩软件。在常规的Linux发行版中,无法通过简单的yum命令来安装该软件。那么在CentOS中,如何安装7ZIP呢(其他环境或者小工具可以百度下哈)?
官网下载地址:http://www.7-zip.org/download.html 最新的版本为22.01。
安装比较简单,依次执行以下命令下载安装:
wget http://nchc.dl.sourceforge.net/project/p7zip/p7zip/9.20.1/p7zip_9.20.1_src_all.tar.bz2
tar -jxvf p7zip_9.20.1_src_all.tar.bz2
cd p7zip_9.20.1
make
make install
最后一步make install
后出现以下信息,即为安装完毕。
./install.sh /usr/local/bin /usr/local/lib/p7zip /usr/local/man /usr/local/share/doc/p7zip
● installing /usr/local/bin/7za
● installing /usr/local/man/man1/7z.1
● installing /usr/local/man/man1/7za.1
● installing /usr/local/man/man1/7zr.1
● installing /usr/local/share/doc/p7zip/README
● installing /usr/local/share/doc/p7zip/ChangeLog
● installing HTML help in /usr/local/share/doc/p7zip/DOCS
下载地址:http://pkgs.repoforge.org/p7zip/,请以最新版为准。
在 CentOS 5.x 32位下安装7ZIP
wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el5.rf.i386.rpm
rpm -ivh p7zip-9.20.1-1.el5.rf.i386.rpm
在 CentOS 5.x 64位下安装7ZIP
wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el5.rf.x86_64.rpm
rpm -ivh p7zip-9.20.1-1.el5.rf.x86_64.rpm
在 CentOS 6.x 32位下安装7ZIP
wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el6.rf.i686.rpm
rpm -ivh p7zip-9.20.1-1.el6.rf.i686.rpm
在 CentOS 6.x 64位下安装7ZIP
wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el6.rf.x86_64.rpm
rpm -ivh p7zip-9.20.1-1.el6.rf.x86_64.rpm
通过上面M2执行安装中,安装RHEL EPEL Repo后,即可使用yum安装7ZIP。
命令如下:
yum install -y p7zip
在macOS中安装就比较方便了,可以使用brew
工具来查找、安装、使用和卸载等操作。
$ brew search 7zip
==> Formulae
7-zip 7zip p7zip zip
当然,搜索7z
也是可以的
$ brew search 7z
==> Formulae
7-zip 7zip p7zip
$ brew install 7zip
==> Downloading https://downloads.sourceforge.net/project/p7zip/p7zip/9.20.1/p7zip_9.20.1_src_all.tar.bz2
######################################################################## 100.0%
==> make all3 CC=clang $(ALLFLAGS) CXX=clang++ $(ALLFLAGS)
==> make DEST_HOME=/usr/local/Cellar/p7zip/9.20.1 DEST_MAN=/usr/local/Cellar/p7zip/9.20.1/share/man install
==> chmod -R +w /usr/local/Cellar/p7zip/9.20.1/share/doc/p7zip
安装过程比较简单,安装后可以使用了。
在windows中就比较简单了,放一个下载连接即可:https://7-zip.org/download.html
注意⚠️:安装了不同的软件,使用命令可能不一样,例如7za
、7zz
等。
使用7zip的命令是7za。安装完成后的使用方法:
7za {a|d|l|e|u|x} 压缩包文件名 {文件列表或目录,可选}
其中,
当实在是不会使用的时候,尽量去百度,那里有你需要的答案。但是在没有网络的时候,就可以使用帮助命令来实现,例如
$ 7za --help
7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=zh_CN.UTF-8,Utf16=on,HugeFiles=on,64 bits,4 CPUs Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz (406F1),ASM,AES-NI)
Usage: 7za <command> [<switches>...] <archive_name> [<file_names>...]
[<@listfiles...>]
<Commands>
a : Add files to archive
b : Benchmark
d : Delete files from archive
e : Extract files from archive (without using directory names)
h : Calculate hash values for files
i : Show information about supported formats
l : List contents of archive
rn : Rename files in archive
t : Test integrity of archive
u : Update files to archive
x : eXtract files with full paths
<Switches>
-- : Stop switches parsing
-ai[r[-|0]]{@listfile|!wildcard} : Include archives
-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
-ao{a|s|t|u} : set Overwrite mode
-an : disable archive_name field
-bb[0-3] : set output log level
-bd : disable progress indicator
-bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
-bt : show execution time statistics
-i[r[-|0]]{@listfile|!wildcard} : Include filenames
-m{Parameters} : set compression Method
-mmt[N] : set number of CPU threads
-o{Directory} : set Output directory
-p{Password} : set Password
-r[-|0] : Recurse subdirectories
-sa{a|e|s} : set Archive name mode
-scc{UTF-8|WIN|DOS} : set charset for for console input/output
-scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files
-scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands
-sdel : delete files after compression
-seml[.] : send archive by email
-sfx[{name}] : Create SFX archive
-si[{name}] : read data from stdin
-slp : set Large Pages mode
-slt : show technical information for l (List) command
-snh : store hard links as links
-snl : store symbolic links as links
-sni : store NT security information
-sns[-] : store NTFS alternate streams
-so : write data to stdout
-spd : disable wildcard matching for file names
-spe : eliminate duplication of root folder for extract command
-spf : use fully qualified file paths
-ssc[-] : set sensitive case mode
-ssw : compress shared files
-stl : set archive timestamp from the most recently modified file
-stm{HexMask} : set CPU thread affinity mask (hexadecimal number)
-stx{Type} : exclude archive type
-t{Type} : Set type of archive
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options
-v{Size}[b|k|m|g] : Create volumes
-w[{path}] : assign Work directory. Empty path means a temporary directory
-x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
-y : assume Yes on all queries
$ 7zz --help
7-Zip (z) 21.07 (x64) : Copyright (c) 1999-2021 Igor Pavlov : 2021-12-26
64-bit locale=zh_CN.UTF-8 Threads:12
Usage: 7zz <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]
<Commands>
a : Add files to archive
b : Benchmark
d : Delete files from archive
e : Extract files from archive (without using directory names)
h : Calculate hash values for files
i : Show information about supported formats
l : List contents of archive
rn : Rename files in archive
t : Test integrity of archive
u : Update files to archive
x : eXtract files with full paths
<Switches>
-- : Stop switches and @listfile parsing
-ai[r[-|0]]{@listfile|!wildcard} : Include archives
-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
-ao{a|s|t|u} : set Overwrite mode
-an : disable archive_name field
-bb[0-3] : set output log level
-bd : disable progress indicator
-bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
-bt : show execution time statistics
-i[r[-|0]]{@listfile|!wildcard} : Include filenames
-m{Parameters} : set compression Method
-mmt[N] : set number of CPU threads
-mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)
-o{Directory} : set Output directory
-p{Password} : set Password
-r[-|0] : Recurse subdirectories for name search
-sa{a|e|s} : set Archive name mode
-scc{UTF-8|WIN|DOS} : set charset for for console input/output
-scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files
-scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands
-sdel : delete files after compression
-seml[.] : send archive by email
-sfx[{name}] : Create SFX archive
-si[{name}] : read data from stdin
-slp : set Large Pages mode
-slt : show technical information for l (List) command
-snh : store hard links as links
-snl : store symbolic links as links
-sni : store NT security information
-sns[-] : store NTFS alternate streams
-so : write data to stdout
-spd : disable wildcard matching for file names
-spe : eliminate duplication of root folder for extract command
-spf : use fully qualified file paths
-ssc[-] : set sensitive case mode
-sse : stop archive creating, if it can't open some input file
-ssp : do not change Last Access Time of source files while archiving
-ssw : compress shared files
-stl : set archive timestamp from the most recently modified file
-stm{HexMask} : set CPU thread affinity mask (hexadecimal number)
-stx{Type} : exclude archive type
-t{Type} : Set type of archive
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options
-v{Size}[b|k|m|g] : Create volumes
-w[{path}] : assign Work directory. Empty path means a temporary directory
-x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
-y : assume Yes on all queries
有些时候,有些命令,还是得看看,忘记的挺快,做笔记吧,让自己看上去不那么像一只摸鱼的兔子。