700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > linux bz2 xz gz 压缩介绍 bz2 gz xz压缩工具

linux bz2 xz gz 压缩介绍 bz2 gz xz压缩工具

时间:2024-02-15 03:35:09

相关推荐

linux bz2 xz gz 压缩介绍 bz2 gz xz压缩工具

压缩打包介绍

常见的压缩文件

Windows .rar .zip .7z

Linux gz、zip、bz2、xz、tar.gz、tar.bz2、tar.xz

压缩对于磁盘节省空间

压缩对于传输传输时间短,节省带宽资源

gzip压缩工具

gzip 1.txt

[root@lsx1 ~]# ls

anaconda-ks.cfg lsx.sh

[root@lsx1 ~]# gzip lsx.sh //压缩之后源文件消失

[root@lsx1 ~]# ls //压缩之后源文件消失

anaconda-ks.cfg lsx.sh.gz

gzip -d 1.txt.gz / gunzip 1.txt.gz

[root@lsx1 ~]# gzip -d lsx.sh.gz //解压缩

[root@lsx1 ~]# ls //解压缩之后压缩包丢失

anaconda-ks.cfg lsx.sh

gzip -# 1.txt //#范围05月14日,默认6

[root@lsx1 ~]# ll -h

-rw-r--r-- 1 root root 169K 11月4 08:33 lsx.txt

[root@lsx1 ~]# gzip lsx.txt //默认6

[root@lsx1 ~]# ll -h

-rw-r--r-- 1 root root 46K 11月4 08:33 lsx.txt.gz

[root@lsx1 ~]# gzip -1 lsx.txt //-1 //数值越大越严谨

[root@lsx1 ~]# ll -h

-rw-r--r-- 1 root root 54K 11月4 08:33 lsx.txt.gz

不能压缩目录

[root@lsx1 ~]# gzip lsx //不能压缩目录

gzip: lsx is a directory -- ignored

zcat 1.txt.gz

[root@lsx1 ~]# zcat lsx.txt.gz //查看文件内容

gzip -c 1.txt > /root/1.txt.gz

[root@lsx1 ~]# gzip -c lsx.txt >./lsx.txt.gz //-c压缩但是源文件不消失,需指定压缩之后文件名

unzip -c /root/1.txt.gz > /tmp/1.txt.new

[root@lsx1 ~]# gzip -dc ./lsx.txt.gz > /tmp/lsx.txt //解压缩。源文件不丢,解压之后文件需指定

[root@lsx1 ~]# ll /tmp/ -h

-rw-r--r-- 1 root root 169K 11月4 08:49 lsx.txt

bzip2压缩工具

bzip2 1.txt / bzip2 -z 1.txt

[root@lsx1 ~]# bzip2 lsx.txt //压缩成bz2文件,源文件消失

[root@lsx1 ~]# ll -h

-rw-r--r-- 1 root root 43K 11月4 08:43 lsx.txt.bz2

-rw-r--r-- 1 root root 46K 11月4 08:44 lsx.txt.gz

bzip2 -d 1.txt.bz2 / bunzip2 1.txt.bz2

[root@lsx1 ~]# bzip2 -d lsx.txt.bz2 //解压缩压缩包消失

[root@lsx1 ~]# ls

anaconda-ks.cfg lsx lsx.txt lsx.txt.gz

bzip -# 1.txt //#范围05月14日,默认9 bzip压缩比gz严谨

[root@lsx1 ~]# bzip2 -1 lsx.txt

[root@lsx1 ~]# ll

-rw-r--r-- 1 root root 45588 11月4 08:43 lsx.txt.bz2

-rw-r--r-- 1 root root 46625 11月4 08:44 lsx.txt.gz

[root@lsx1 ~]# bzip2 -9 lsx.txt

[root@lsx1 ~]# ll -h

-rw-r--r-- 1 root root 43K 11月4 08:43 lsx.txt.bz2

-rw-r--r-- 1 root root 46K 11月4 08:44 lsx.txt.gz

不能压缩目录

[root@lsx1 ~]# bzip2 lsx

bzip2: Input file lsx is a directory.

bzcat 1.txt.bz2

[root@lsx1 ~]# bzcat lsx.txt.bz2 //查看文件内容

bzip2 -c 1.txt > /root/1.txt.bz

[root@lsx1 ~]# bzip2 -c ./lsx.txt>./lsx.txt.bz2 //压缩。源文件不消失,指定压缩后文件

[root@lsx1 ~]# ls

lsx.txt lsx.txt.bz2 lsx.txt.gz

bzip2 -c -d /root/1.txt.bz2 > /tmp/1.txt.new2

[root@lsx1 ~]# bzip2 -dc lsx.txt.bz2 > /tmp/lsx.bzip2 //解压压缩包不消失,需指定压缩后文件

[root@lsx1 ~]# ls /tmp/

lsx.bzip2

xz压缩工具

xz 1.txt / xz -z 1.txt

[root@lsx1 ~]# xz lsx.txt //压缩文件

[root@lsx1 ~]# ll -h

-rw-r--r-- 1 root root 43K 11月4 09:10 lsx.txt.bz2

-rw-r--r-- 1 root root 46K 11月4 08:44 lsx.txt.gz

-rw-r--r-- 1 root root 42K 11月4 09:09 lsx.txt.xz

xz -d 1.txt.xz / unxz 1.txt.xz

[root@lsx1 ~]# xz -d lsx.txt.xz //解压,压缩包消失

[root@lsx1 ~]# ll -h

-rw-r--r-- 1 root root 169K 11月4 09:09 lsx.txt

-rw-r--r-- 1 root root 43K 11月4 09:10 lsx.txt.bz2

-rw-r--r-- 1 root root 46K 11月4 08:44 lsx.txt.gz

xz -# 1.txt //#范围05月14日,默认9压缩比:xz压缩最严谨,次bz2,gz

[root@lsx1 ~]# xz -9 lsx.txt

[root@lsx1 ~]# ll -h

-rw-r--r-- 1 root root 43K 11月4 09:10 lsx.txt.bz2

-rw-r--r-- 1 root root 46K 11月4 08:44 lsx.txt.gz

-rw-r--r-- 1 root root 42K 11月4 09:09 lsx.txt.xz

不能压缩目录

[root@lsx1 ~]# xz lsx

xz: lsx: Is a directory, skipping

xzcat 1.txt.xz

[root@lsx1 ~]# xzcat lsx.txt.xz //查看文件内容

xz -c 1.txt > /root/1.txt.xz

[root@lsx1 ~]# xz -c lsx.txt>./lsx.txt.xz //压缩。-c源文件不消失,需指定压缩文件

[root@lsx1 ~]# ls

lsx.txt lsx.txt.xz

xz -d -c /root/1.txt.xz > 1.txt.new3

[root@lsx1 ~]# xz -dc lsx.txt.xz > lsx.txt.xz.new //解压缩,-c指定解压缩之后文件,压缩包不消失

[root@lsx1 ~]# ls

lsx.txt.xz

lsx.txt.xz.new

本文转自 虾米的春天 51CTO博客,原文链接:/lsxme/1980533,如需转载请自行联系原作者

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。