如何grep压缩非标准文本文件的内容

问题描述 投票:-1回答:1

在我的Windows-10 PC上,我安装了Ubuntu应用程序。在那里,我想对一组zipfiles的内容进行grep,但让我们从1个zipfile开始。我的zipfile包含两个文件:crashdump和errorlog(文本文件),包含一些信息。我对该错误日志文件中的信息特别感兴趣:

<grep_inside> zipfile.zip "Access violation"

到现在为止,这是我最好的结果:

unzip -c zipfile.zip error.log

这显示了错误日志文件,但它将其显示为hexdump,这使得无法在其上启动grep。

正如在不同的网站上提出的那样,我也尝试过以下命令:vimviewzcatzlesszgrep,所有这些都不能用于不同的原因。

一些进一步调查

这个问题不是this post的重复,建议,我认为问题是由日志文件的编码引起的,正如您在解压缩错误日志文件后可以在其他基本Linux命令的结果中看到的那样:

emacs error.log
... caused an Access Violation (0xc0000005)

cat error.log
. . . c a u s e d   a n   A c c e s s   V i o l a t i o n   ( 0 x c 0 0 0 0 0 0 5 )

显然,error.log文件未被识别为简单的文本文件:

file error.log
error.log : Little-endian UTF-16 Unicode text, with very long lines, with CRLF line terminators
linux grep unzip
1个回答
0
投票

this post on grepping non-standard text files,我找到了答案:

unzip -c zipfile.zip error.log | grep -a "A.c.c.e.s.s"

现在我有一些东西可以开始了。

谢谢大家,感谢您的合作。

© www.soinside.com 2019 - 2024. All rights reserved.