tar -xzvf filename.tar.gz
-xzvf
這其中四個字母的順序可以隨意顛倒
將demo.c 文件壓縮成demo.tar.gz 文件
tar -czvf demo.tar.gz demo.c
以上四個字母的順序位置同理
gzip filename
gzip 壓縮命令非常簡單,甚至不需要指定壓縮之后的壓縮包名,只需指定源文件名即可。
缺點:壓縮文件生成,但是源文件也消失了
gzip -c demo.c>demo.c.gz
使用-c選項,但是不讓壓縮數據輸出到屏幕上,而是重定向到壓縮文件中,這樣可以縮文件的同時不刪除源文件
[root@localhost ~]# mkdir test
[root@localhost ~]# touch test/test1
[root@localhost ~]# touch test/test2
[root@localhost ~]# touch test/test3 #建立測試目錄,并在里面建立幾個測試文件
[root@localhost ~]# gzip -r test/
#壓縮目錄,并沒有報錯
[root@localhost ~]# ls
anaconda-ks.cfg anaconda-ks.cfg.gz install.log.gz install.log.syslog test
#但是查看發現test目錄依然存在,并沒有變為壓縮文件
[root@localhost ~]# ls test/
testl .gz test2.gz test3.gz
#原來gzip命令不會打包目錄,而是把目錄下所有的子文件分別壓縮
linux怎么解壓gz文件?在 Linux 中,打包和壓縮是分開處理的。而 gzip 命令只會壓縮,不能打包,所以才會出現沒有打包目錄,而只把目錄下的文件進行壓縮的情況。
gzip -dv filename
or
gzip -dv *
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态