天天看點

centos解壓zip指令_CentOS「linux」學習筆記8:壓縮和解壓類指令​linux基礎操作:主要介紹了壓縮和解壓類指令

centos解壓zip指令_CentOS「linux」學習筆記8:壓縮和解壓類指令​linux基礎操作:主要介紹了壓縮和解壓類指令

​linux基礎操作:主要介紹了壓縮和解壓類指令

1.gzip/gunzip[打包壓縮解壓檔案,打包壓縮後為.gz格式]

例子1:gzip /home/test/hello.go 表示将test目錄下的hello.go檔案打包壓縮,并且原檔案會被删除掉。例子2:gzip hello.go test.go hh.txt 表示将三個檔案打包壓縮。例子3:gunzip /home/hello.txt.gz 表示将home目錄下的hello.txt.gz檔案解壓出來。特别說明:gzip在壓縮和解壓檔案的同時會删除掉原檔案。另外gzip非常用的壓縮方式。
           

2.zip/unzip[打包壓縮解壓檔案或目錄,類似Win下的zip壓縮軟體,打包壓縮後格式為zip格式。]

例子1:zip hello.zip hello.go 表示将hello.go檔案壓縮為hello.zip檔案。其中的hello.zip可以按需求命名。例子2:zip -r test.zip /home/test/ 表示将test檔案夾壓縮為test.zip檔案。例子3:unzip hello.zip 表示解壓hello.zip的檔案。例子4:unzip hello.zip -d /home/test 表示将hello.zip檔案解壓到test目錄下。特别說明:使用zip壓縮解壓檔案時會保留原檔案,zip也是常用的壓縮方式之一。
           

3.tar[打包壓縮和解壓檔案或目錄,linux下常用,打包壓縮後格式為.tar.gz格式。]

例子1:tar -zcvf hello.tar.gz hello.go 表示将hello.go檔案打包壓縮成hello.tar.gz檔案。例子2:tar -zcvf hello.tar.gz hello.go test.txt 表示打包壓縮多個檔案。例子3:tar -zcvf hello.tar.gz /home/test 表示将test目錄打包壓縮名為hello.tar.gz的檔案。例子4:tar -zxvf hello.tar.gz 表示解壓hello.tar.gz檔案。例子5:tar -zxvf hello.tar.gz -C /home/test 表示将hello.tar.gz解壓到test目錄去。特别說明:比較常用的壓縮和解壓方式。tar打包和壓縮是靠參數來決定的,tar可選參數: -z表示打包時壓縮檔案 -f表示指定壓縮後的檔案名 -v表示顯示壓縮和解壓過程的詳細資訊 -c表示打包.tar檔案 -C表示指定解壓的目錄 -x表示解壓檔案通常使用時會直接使用組合參數如:壓縮檔案時使用:tar -zcvf 解壓檔案時使用:tar -zxvf 
           

繼續閱讀