最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

linux gzip压缩

来源:动视网 责编:小OO 时间:2025-09-29 10:53:48
文档

linux gzip压缩

linux-yptrs:/#ll/etc/Muttrc-rw-r--r--1rootroot117386Nov252009/etc/Muttrclinux-yptrs:/#cp/etc/Muttrcfile1linux-yptrs:/#llfile1-rw-r--r--1rootroot117386Jul2013:24file1linux-yptrs:/#gzipfile1//压缩file1文件linux-yptrs:/#llfile1.gz-rw-r--r--1rootroot33421Ju
推荐度:
导读linux-yptrs:/#ll/etc/Muttrc-rw-r--r--1rootroot117386Nov252009/etc/Muttrclinux-yptrs:/#cp/etc/Muttrcfile1linux-yptrs:/#llfile1-rw-r--r--1rootroot117386Jul2013:24file1linux-yptrs:/#gzipfile1//压缩file1文件linux-yptrs:/#llfile1.gz-rw-r--r--1rootroot33421Ju
linux-yptrs:/ # ll /etc/Muttrc

-rw-r--r-- 1 root root 117386 Nov 25 2009 /etc/Muttrc

linux-yptrs:/ # cp /etc/Muttrc file1

linux-yptrs:/ # ll file1

-rw-r--r-- 1 root root 117386 Jul 20 13:24 file1

linux-yptrs:/ # gzip file1 //压缩file1文件

linux-yptrs:/ # ll file1.gz

-rw-r--r-- 1 root root 33421 Jul 20 13:24 file1.gz

linux-yptrs:/ # gzip -l file1.gz

compressed uncompressed ratio uncompressed_name

33421 117386 71.5% file1

linux-yptrs:/ # gzip -d file1.gz //解压缩FILE1文件

linux-yptrs:/ # ll file1

-rw-r--r-- 1 root root 117386 Jul 20 13:24 file1

linux-yptrs:/ # gunzip file1.gz //gunzip和gzip -d一致

linux-yptrs:/ # ll file1

-rw-r--r-- 1 root root 117386 Jul 20 13:24 file1

压缩gzip后,原来的文件会消失成为file.gz的压缩文件;

但是可以通过gzip中的参数-c,保留原来的文件不消失;

linux-yptrs:/ # gzip -c file1 > file1.gz

linux-yptrs:/ # ll file*

-rw-r--r-- 1 root root 117386 Jul 20 13:24 file1

-rw-r--r-- 1 root root 33421 Jul 20 13:31 file1.gz

另外-c还可以将多个文件的内容合并为一个压缩文件保存

linux-yptrs:/ # touch file2

linux-yptrs:/ # vi file2

apple

bag

cat

dog

egg

fog

ghost

linux-yptrs:/ # gzip -c file1 file2 > file3.gz

linux-yptrs:/ # gzip -d file3.gz //gunzip file3.gz

linux-yptrs:/ # tail -10 file3

# to the one used by ``$status_format''.

#

#

apple

bag

cat

dog

egg

fog

ghost

linux-yptrs:/ # gzip -d file3.gz //解压FILE3.GZ

linux-yptrs:/ # ls

file1.gz file3 file1 file2.gz file2

//发现原来的file3.gz压缩文件解压以后也没有了,如何看压缩文件而不用

解压呢?

1)先解压,在通过gzip -c file > file.gz

2)通过 gzip -d -c file.gz 即可

linux-yptrs:/ # gzip -d -c file3.gz | grep bag

bag

内容的附加压缩到同一个文件

linux-yptrs:/ # gzip -c file2 >file4.gz

linux-yptrs:/ # gzip -d -c file4.gz

apple

bag

linux-yptrs:/ # gzip -c file3 > file4.gz

linux-yptrs:/ # gzip -d -c file4.gz

cat

dot

//发现此时file4.gz的内容会被file3所覆盖;所以我们可用>>符号来传输

linux-yptrs:/ # gzip -c file2 > file4.gz

linux-yptrs:/ # gzip -c file3 >> file4.gz

linux-yptrs:/ # gzip -d -c file4.gz

apple

bag

cat

dot

linux-yptrs:/ # zcat file4.gz

apple

bag

cat

dot

如何将文件下的文件压缩,以及文件夹下的子文件夹文件压缩

linux-yptrs:/ # mkdir -p dir/dir1

linux-yptrs:/ # cp file2 dir/file2_1

linux-yptrs:/ # cp file3 dir/dir1/file3_1

linux-yptrs:/ # gzip -r dir //-r参数进行递归压缩

linux-yptrs:/ # cd dir/

linux-yptrs:/dir # ls

dir1 file2_1.gz

linux-yptrs:/dir # cd dir1/

linux-yptrs:/dir/dir1 # ls

file3_1.gz

递归解压缩

linux-yptrs:/ # gunzip -r dir

linux-yptrs:/ # cd dir/

linux-yptrs:/dir # ls

dir1 file2

linux-yptrs:/dir # cd dir1/

linux-yptrs:/dir/

dir1 # ls

file3

文档

linux gzip压缩

linux-yptrs:/#ll/etc/Muttrc-rw-r--r--1rootroot117386Nov252009/etc/Muttrclinux-yptrs:/#cp/etc/Muttrcfile1linux-yptrs:/#llfile1-rw-r--r--1rootroot117386Jul2013:24file1linux-yptrs:/#gzipfile1//压缩file1文件linux-yptrs:/#llfile1.gz-rw-r--r--1rootroot33421Ju
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top