如何在不解压缩的情况下从.gz压缩文件中获取几行 [英] How to get few lines from a .gz compressed file without uncompressing
本文介绍了如何在不解压缩的情况下从.gz压缩文件中获取几行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从gzip解压缩的文件中获取前几行? 我尝试了zcat,但是它抛出了错误
How to get the first few lines from a gziped file ? I tried zcat, but its throwing an error
zcat CONN.20111109.0057.gz|head
CONN.20111109.0057.gz.Z: A file or directory in the path name does not exist.
推荐答案
zcat(1)
可以由compress(1)
或gzip(1)
提供.在您的系统上,它似乎是compress(1)
-它正在寻找扩展名为.Z
的文件.
zcat(1)
can be supplied by either compress(1)
or by gzip(1)
. On your system, it appears to be compress(1)
-- it is looking for a file with a .Z
extension.
切换到gzip -cd
代替zcat
,您的命令应该可以正常运行:
Switch to gzip -cd
in place of zcat
and your command should work fine:
gzip -cd CONN.20111109.0057.gz | head
说明
-c --stdout --to-stdout
Write output on standard output; keep original files unchanged. If there are several input files, the output consists of a sequence of independently compressed members. To obtain better compression, concatenate all input files before compressing
them.
-d --decompress --uncompress
Decompress.
这篇关于如何在不解压缩的情况下从.gz压缩文件中获取几行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文