Centos7中使用7zip壓縮工具
7-Zip是一個支援7z(它實現了LZMA壓縮演算法,具有非常高的壓縮比)、LZMA2、XZ、ZIP、Zip64、CAB、ARJ、GZIP、BZIP2、TAR、CPIO、RPM、ISO、大多數檔案系統映像和DEB格式的檔案歸檔器。RAR格式由於不是免費許可,已經被刪除了。 |
- Centos7.7 Minimal
- p7zip-16.02
預設Centos7沒有安裝p7zip安裝包,預設源裡面也沒有這個安裝包,需要安裝epel源才能安裝p7zip安裝包。
[root@localhost ~]# yum -y install epel-release [root@localhost ~]# yum -y install p7zip p7zip-plugins
7z 命令提供的函式字母與 命令行選項類似,但使用時不使用 -。這些引數字母告訴命令它需要執行的函式。
建立一個壓縮包使用 a引數
建立一個7z格式的壓縮包:
[root@localhost ~]# 7z a files.7z file1.txt file2.txt file3.txt file4.txt 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Scanning the drive: 4 files, 0 bytes Creating archive: files.7z Items to compress: 4 Files read from disk: 0 Archive size: 143 bytes (1 KiB) Everything is Ok
執行完命令,檢視一下是否已經建立7z格式的壓縮包
建立一個包含目錄的壓縮包:
[root@localhost ~]# 7z a gpg.7z .gnupg/ 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Scanning the drive: 2 folders, 5 files, 8280 bytes (9 KiB) Creating archive: gpg.7z Items to compress: 7 Files read from disk: 2 Archive size: 4157 bytes (5 KiB) Everything is Ok [root@localhost ~]#
7zip還可以壓縮、解壓縮其他格式的壓縮包。比如:建立一個.zip格式的壓縮包。
[root@localhost ~]# 7z a files.zip file{1..4}.txt 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Scanning the drive: 4 files, 0 bytes Creating archive: files.zip Items to compress: 4 Files read from disk: 4 Archive size: 542 bytes (1 KiB) Everything is Ok
列出壓縮包的內容使用 l引數:
[root@localhost ~]# 7z l gpg.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Scanning the drive for archives: 1 file, 4157 bytes (5 KiB) Listing archive: gpg.7z -- Path = gpg.7z Type = 7z Physical Size = 4157 Headers Size = 278 Method = LZMA2:12k Solid = + Blocks = 1 Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 2020-01-04 18:24:05 D.... 0 0 .gnupg 2020-01-04 18:22:36 D.... 0 0 .gnupg/private-keys-v1.d 2020-01-04 18:24:48 ....A 0 0 .gnupg/S.gpg-agent 2020-01-04 18:22:36 ....A 0 0 .gnupg/pubring.gpg 2020-01-04 18:24:05 ....A 0 0 .gnupg/secring.gpg 2020-01-04 18:22:36 ....A 7680 3879 .gnupg/gpg.conf 2020-01-04 18:24:52 ....A 600 .gnupg/random_seed ------------------- ----- ------------ ------------ ------------------------ 2020-01-04 18:24:52 8280 3879 5 files, 2 folders
使用 e來解壓檔案,解壓所有檔案到當前目錄。(不推薦使用)
[root@localhost test]# 7z e gpg.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Scanning the drive for archives: 1 file, 4157 bytes (5 KiB) Extracting archive: gpg.7z -- Path = gpg.7z Type = 7z Physical Size = 4157 Headers Size = 278 Method = LZMA2:12k Solid = + Blocks = 1 Everything is Ok Folders: 2 Files: 5 Size: 8280 Compressed: 4157
可以看到所有檔案都解壓到當前目錄了。
現在使用
x引數解壓檔案看一下。
[root@localhost test]# 7z x gpg.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Scanning the drive for archives: 1 file, 4157 bytes (5 KiB) Extracting archive: gpg.7z -- Path = gpg.7z Type = 7z Physical Size = 4157 Headers Size = 278 Method = LZMA2:12k Solid = + Blocks = 1 Everything is Ok Folders: 2 Files: 5 Size: 8280 Compressed: 4157
可以看到解壓出來的檔案,按照原來檔案的目錄形式解壓出來的。
一段時間之後,需要將一些新檔案新增到資料夾中,並且希望將他們新增到壓縮包裡面,可以不用建立一個新的壓縮包,只需要更新現有的壓縮包就可以。
首先將test目錄壓縮
[root@localhost test]# 7z a files.7z test/ 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Scanning the drive: 1 folder, 4 files, 0 bytes Creating archive: files.7z Items to compress: 5 Files read from disk: 0 Archive size: 158 bytes (1 KiB) Everything is Ok
在test資料夾中建立幾個檔案,然後再更新壓縮包:
[root@localhost test]# touch test/file{5..10}.txt [root@localhost test]# 7z u files.7z test/ 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Open archive: files.7z -- Path = files.7z Type = 7z Physical Size = 158 Headers Size = 158 Solid = - Blocks = 0 Scanning the drive: 1 folder, 10 files, 0 bytes Updating archive: files.7z Items to compress: 7 Files read from disk: 0 Archive size: 186 bytes (1 KiB) Everything is Ok
檢視一下是否已經新增檔案。
[root@localhost test]# 7z l files.7z 7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz (906EA),ASM,AES-NI) Scanning the drive for archives: 1 file, 186 bytes (1 KiB) Listing archive: files.7z -- Path = files.7z Type = 7z Physical Size = 186 Headers Size = 186 Solid = - Blocks = 0 Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 2020-03-11 14:24:54 D.... 0 0 test 2020-03-11 14:18:22 ....A 0 0 test/file1.txt 2020-03-11 14:24:54 ....A 0 0 test/file10.txt 2020-03-11 14:18:22 ....A 0 0 test/file2.txt 2020-03-11 14:18:22 ....A 0 0 test/file3.txt 2020-03-11 14:18:22 ....A 0 0 test/file4.txt 2020-03-11 14:24:54 ....A 0 0 test/file5.txt 2020-03-11 14:24:54 ....A 0 0 test/file6.txt 2020-03-11 14:24:54 ....A 0 0 test/file7.txt 2020-03-11 14:24:54 ....A 0 0 test/file8.txt 2020-03-11 14:24:54 ....A 0 0 test/file9.txt ------------------- ----- ------------ ------------ ------------------------ 2020-03-11 14:24:54 0 0 10 files, 1 folders
7z格式的壓縮比例比ZIP格式的壓縮比例高30%-50%。
原文地址: https://www.linuxprobe.com/centos7-7zip-compression.html
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31559985/viewspace-2679734/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux 高效壓縮工具之xz的壓縮解壓使用Linux
- CentOS7中安裝LZO壓縮程式CentOS
- Linux打包壓縮解壓工具Linux
- Keka for Mac(壓縮解壓工具)Mac
- Keka for Mac壓縮解壓工具Mac
- MyZip for mac解壓壓縮工具Mac
- Mac壓縮解壓工具:Keka for MacMac
- A-Zippr for Mac 壓縮解壓工具Mac
- pigz更快的壓縮和解壓工具
- NET中SharpZipLib 的使用(一)【壓縮與解壓】
- NET中SharpZipLib 的使用(二)【Web中壓縮與解壓】Web
- Keka for Mac(壓縮解壓工具) 1.3.6中文啟用版Mac
- Linux中檔案的壓縮和解壓縮Linux
- pdf怎麼壓縮,好用的pdf壓縮工具介紹
- png格式如何壓縮,圖片壓縮工具哪個好
- 影像體積壓縮工具JPEG Jackal更好的壓縮圖片
- Keka for Mac(壓縮解壓工具) v1.3.5中文版Mac
- Keka for Mac(壓縮解壓工具) v1.3.3中文版Mac
- Centos7系統---檔案壓縮與解壓命令詳解。CentOS
- 實用的壓縮解壓工具:WinZip for MacMac
- SmallImage for Mac(圖片壓縮工具)Mac
- PDF Squeezer for Mac(PDF壓縮工具)Mac
- Nginx網路壓縮 CSS壓縮 圖片壓縮 JSON壓縮NginxCSSJSON
- Keka Mac:高效簡潔的壓縮解壓工具Mac
- CentOS中zip壓縮和unzip解壓縮命令詳解CentOS
- 使用js寫一個圖片壓縮的小工具JS
- Chrome外掛:切圖壓縮工具Chrome
- 簡單好用的js 壓縮工具JS
- Image Optimizer for Mac(圖片壓縮工具)Mac
- PDF Squeezer for mac(簡易壓縮工具)Mac
- 高效能 gzip 壓縮工具 pgzip
- WinZip Pro 9 for Mac 專業zip壓縮解壓工具Mac
- 檔案壓縮和解壓縮
- EXPAND命令是Windows作業系統中的一個命令列工具,用於解壓縮檔案。它可以將Windows壓縮檔案(.cab)中的檔案提取到指定的目錄中。EXPAND命令通常用於在命令列中執行解壓縮操作,而不需要使用圖形介面中的壓縮工具。Windows作業系統命令列
- FastZip for Mac_Mac解壓軟體_Mac壓縮_Mac解壓工具ASTMac
- Linux下各壓縮方式測試(壓縮率和使用時間)Linux
- tinypng upload一鍵壓縮上傳工具
- PDF文件壓縮工具:Cisdem PDF Compressor for MacMac