Linux學習筆記四之壓縮解壓命令

來源:互聯網
上載者:User

Linux學習筆記四之壓縮解壓命令 相關連結:Linux學習筆記一之檔案操作命令http://www.bkjia.com/os/201211/169196.html;Linux學習筆記二之許可權管理命令http://www.bkjia.com/os/201211/169485.html;Linux學習筆記三之檔案搜尋的命令http://www.bkjia.com/os/201211/169489.html 1、壓縮檔  www.2cto.com   gzip 壓縮檔   格式為.gz  特點:只能壓縮檔不能壓縮目錄;不保留源檔案 gzip 檔案名稱   [root@CentOS-Test data]# gzip xx_lhc.txt  [root@CentOS-Test data]# ls bak  lost+found  testdir1  testdir2  xx_lhc.txt.gz2、解壓縮檔案 gzip -d  [root@CentOS-Test data]# gzip -d xx_lhc.txt.gz  [root@CentOS-Test data]# ls bak  lost+found  testdir1  testdir2  xx_lhc.txt3、壓縮檔夾 tar 打包的目錄名  格式為.tar.gz tar參數: -c:產生.tar打包檔案  -v:顯示詳細資料   -f:指定壓縮後的檔案名稱  -z:打包同時壓縮 [root@CentOS-Test data]# tar -zcvf newdir.tar.gz testdir1 testdir1/ 可是使用file filename來判斷檔案是什麼類型 如果上述命令在某些linux版本的作業系統下不支援,可是先打包再壓縮 [root@CentOS-Test data]# tar -cvf xx_lhc.tar  xx_lhc.txt   [root@CentOS-Test data]# gzip xx_lhc.tar4、解壓縮檔案夾 tar命令解壓縮參數 -x:解包.tar檔案  -f:指定解壓檔案 -v:顯示詳細資料 -z:解壓 [root@CentOS-Test data]# tar -xzvf xx_lhc.tar.gz  xx_lhc.txt  zip壓縮命令,不僅可以壓縮檔,還可以壓縮目錄(使用-r參數),並且壓縮檔時源檔案依然存在 例如: 壓縮檔: [root@CentOS-Test data]# zip xx_lhc.zip xx_lhc.txt    adding: xx_lhc.txt (deflated 22%)  22%是壓縮比 [root@CentOS-Test data]# ll -rw-r--r--. 1 root root   428 11月 18 20:00 xx_lhc.txt -rw-r--r--. 1 root root   502 11月 18 21:30 xx_lhc.zip  壓縮目錄 例如: [root@CentOS-Test data]# zip -r bak.zip bak   adding: bak/ (stored 0%)   adding: bak/lhc.txt (deflated 22%)   adding: bak/李海超個人資訊.txt (deflated 22%) .zip格式的解壓縮 命令:unzip 壓縮包名稱  bzip2壓縮命令,適合壓縮檔比較大的檔案,壓縮比很高,格式為.bz2,只能壓縮檔 壓縮檔,使用-k參數可以保留原檔案名稱 [root@CentOS-Test data]# bzip2 -k xx_lhc.txt -rw-r--r--. 1 root root   378 11月 18 20:00 xx_lhc.txt.bz2 解壓縮.bz2格式的檔案 [root@CentOS-Test data]# bunzip2 xx_lhc.txt.bz2 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.