今天使用linux解压的时候遇到了不能解压的问题,然后就看了一些文档,写一个解决方案
Linux version 3.10.0-957.10.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Mon Mar 18 15:06:45 UTC 2019
首先查看下自己系统:
$ cat /proc/version
Linux version 3.10.0-957.10.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Mon Mar 18 15:06:45 UTC 2019
当执行unzip 提示如下:
-bash: unzip: 未找到命令
说明未安装过, 只需执行如下命令即可. 同样适用 Unix 内核系统.
一. Install 安装
[root@dev-redis agent]# yum install -y unzip zip
已加载插件:fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 8.3 kB 00:00:00
- base: mirrors.cn99.com
- epel: mirrors.aliyun.com
- extras: ftp.sjtu.edu.cn
- updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 5.3 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/4): epel/x86_64/updateinfo | 976 kB 00:00:00
(2/4): epel/x86_64/primary_db | 6.7 MB 00:00:00
(3/4): extras/7/x86_64/primary_db | 200 kB 00:00:00
(4/4): updates/7/x86_64/primary_db | 5.7 MB 00:00:00
正在解决依赖关系
–> 正在检查事务
—> 软件包 unzip.x86_64.0.6.0-19.el7 将被 安装
—> 软件包 zip.x86_64.0.3.0-11.el7 将被 安装
–> 解决依赖关系完成
依赖关系解决
===========================================================================================================================================================================================
Package 架构 版本 源 大小
===========================================================================================================================================================================================
正在安装:
unzip x86_64 6.0-19.el7 base 170 k
zip x86_64 3.0-11.el7 base 260 k
事务概要
===========================================================================================================================================================================================
安装 2 软件包
总下载量:430 k
安装大小:1.1 M
Downloading packages:
(1/2): unzip-6.0-19.el7.x86_64.rpm | 170 kB 00:00:00
(2/2): zip-3.0-11.el7.x86_64.rpm | 260 kB 00:00:00
总计 2.6 MB/s | 430 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : zip-3.0-11.el7.x86_64 1/2
正在安装 : unzip-6.0-19.el7.x86_64 2/2
验证中 : unzip-6.0-19.el7.x86_64 1/2
验证中 : zip-3.0-11.el7.x86_64 2/2
已安装:
unzip.x86_64 0:6.0-19.el7 zip.x86_64 0:3.0-11.el7
完毕!
到这里就安装完毕可以使用unzip 了
二. 查看用法
然后可以查看下相关用法:
$ unzip -h
UnZip 6.00 of 20 April 2009, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
Default action is to extract files in list, except those in xlist, to exdir;
file[.zip] may be a wildcard. -Z => ZipInfo mode (“unzip -Z” for usage).
-p extract files to pipe, no messages -l list files (short format)
-f freshen existing files, create none -t test compressed archive data
-u update files, create if necessary -z display archive comment only
-v list verbosely/show version info -T timestamp archive to latest
-x exclude files that follow (in xlist) -d extract files into exdir
modifiers:
-n never overwrite existing files -q quiet mode (-qq => quieter)
-o overwrite files WITHOUT prompting -a auto-convert any text files
-j junk paths (do not make directories) -aa treat ALL files as text
-U use escapes for all non-ASCII Unicode -UU ignore any Unicode fields
-C match filenames case-insensitively -L make (some) names lowercase
-X restore UID/GID info -V retain VMS version numbers
-K keep setuid/setgid/tacky permissions -M pipe through “more” pager
-O CHARSET specify a character encoding for DOS, Windows and OS/2 archives
-I CHARSET specify a character encoding for UNIX and other archives
See “unzip -hh” or unzip.txt for more help. Examples:
unzip data1 -x joe => extract all files except joe from zipfile data1.zip
unzip -p foo | more => send contents of foo.zip via pipe into program more
unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
解压命令大全
tar
解包:tar zxvf filename.tar
打包:tar czvf filename.tar dirname
gz命令
解压1:gunzip filename.gz
解压2:gzip -d filename.gz
压缩:gzip filename
.tar.gz 和 .tgz
解压:tar zxvf filename.tar.gz
压缩:tar zcvf filename.tar.gz dirname
压缩多个文件:tar zcvf filename.tar.gz dirname1 dirname2 dirname3.....
bz2命令
解压1:bzip2 -d filename.bz2
解压2:bunzip2 filename.bz2
压缩:bzip2 -z filename
.tar.bz2
解压:tar jxvf filename.tar.bz2
压缩:tar jcvf filename.tar.bz2 dirname
bz命令
解压1:bzip2 -d filename.bz
解压2:bunzip2 filename.bz
.tar.bz
解压:tar jxvf filename.tar.bz
z命令
解压:uncompress filename.z
压缩:compress filename
.tar.z
解压:tar zxvf filename.tar.z
压缩:tar zcvf filename.tar.z dirname
zip命令
解压:unzip filename.zip
压缩:zip filename.zip dirname