今天使用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