Linux命令-zcat

作者: testerzhang | 来源:发表于2020-05-27 15:40 被阅读0次

前言

如果要在不解压缩压缩文件的情况下查看压缩文件的内容,该怎么办? 为此,您需要zcat命令实用程序。

例子:

  • 直接查看gzip压缩包的文件内容
$ cat 1.txt 
1 apple
2 banana
$ gzip  1.txt 
$ ls -lrt
-rw-r--r-- 1 aiwm aisoft 41 5月  27 15:34 1.txt.gz
$ zcat  1.txt.gz 
1 apple
2 banana
  • 直接查看txt文件,需要加-f 参数 等同于cat
$ cat 2.txt 
11 apple
12 banana
-bash-4.1$ zcat 2.txt 

gzip: 2.txt: not in gzip format
-bash-4.1$ zcat -f 2.txt 
11 apple
12 banana
  • 直接压缩文件的属性(压缩大小,未压缩大小,比率 - 压缩率(0.0%,如果未知),uncompressed_name(未压缩文件的名称)
$ zcat -l  1.txt.gz 
         compressed        uncompressed  ratio uncompressed_name
                 41                  17  47.1% 1.txt

相关文章

网友评论

    本文标题:Linux命令-zcat

    本文链接:https://www.haomeiwen.com/subject/aubwahtx.html