1. 程式人生 > >gzip,bzip2,xz壓縮工具

gzip,bzip2,xz壓縮工具

gzip bzip2 xz

壓縮打包介紹
  • windows:.rar .zip .7z
  • linux: .zip,.gz,.bz2,.xz,.tar.gz,.tar.bz2,.tar.xz

gzip壓縮工具

  • gzip 1.txt壓縮文件
    [root@aminglinux-02 d6z]# gzip 1.txt 
    [root@aminglinux-02 d6z]# ls
    1.txt.gz
  • gzip -# 1.txt //#範圍1-9,默認6,9壓縮最狠,不能壓縮目錄
  • gzip -d 1.txt.gz / gunzip 1.txt.gz解壓縮文件
    [root@aminglinux-02 d6z]# gzip -d 1.txt.gz 
    [root@aminglinux-02 d6z]# ll
    總用量 2996
    -rw-r--r--. 1 root root 3065940 6月  22 21:03 1.txt
    [root@aminglinux-02 d6z]# gunzip 1.txt.gz
    [root@aminglinux-02 d6z]# ls
    1.txt
  • zcat 1.txt.gz查看壓縮文件,實際是先解壓縮在查看
  • gunzip -c /root/1.txt.gz > /tmp/1.txt解壓縮文件到另一個目錄,並保留源壓縮文件
  • gzip -c /root/1.txt > /tmp/1.txt.gz壓縮文件到另一個目錄,並保留源文件
  • file 1.txt.gz可以查看文件的類型
    [root@aminglinux-02 d6z]# file 1.txt 
    1.txt: C source, UTF-8 Unicode text
    [root@aminglinux-02 d6z]# gzip 1.txt 
    [root@aminglinux-02 d6z]# file 1.txt.gz 
    1.txt.gz: gzip compressed data, was "1.txt", from Unix, last modified: Thu Jun 22 21:03:53 2017

bzip2壓縮工具

  • bzip2 1.txt / bzip2 -z 1.txt壓縮文件,不能壓縮目錄
  • bzip2 -d 1.txt.bz2 / bunzip2 1.txt.bz2解壓文件
  • bzip -# 1.txt //#範圍1-9,默認9
  • bzcat 1.txt.bz2查看壓縮文件
  • bzip2 -c 1.txt > /root/1.txt.bz2壓縮文件到另一個目錄,並保留源文件
  • bzip2 -c -d /root/1.txt.bz2 > /tmp/2.txt解壓縮文件到另一個目錄並改名,並保留源壓縮文件

xz壓縮工具

  • 用法和和上面兩個一樣,壓縮比最狠為xz,其次是bzip2,最後是gz

gzip,bzip2,xz壓縮工具