Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 使用Powershell grep搜索单词模式;例外情况;归档_Unix_Powershell_Grep - Fatal编程技术网

Unix 使用Powershell grep搜索单词模式;例外情况;归档

Unix 使用Powershell grep搜索单词模式;例外情况;归档,unix,powershell,grep,Unix,Powershell,Grep,背景: 我有一个日志服务器,其中包含大量包含文本日志信息的gzip文件 在这些日志中,文本文件中写入了“异常”标记,我想使用powershell在日志文本文件中查找所有可用的“异常”标记条目 我一直在尝试使用Powershell和以下cmdlet选项,但在使用Select String在文本文件中“Grep”出单词模式“Exception”之前,我无法获取gzip文件文本文件中的内容 Get-ChildItem '##Location of my log files directory###'

背景:

我有一个日志服务器,其中包含大量包含文本日志信息的gzip文件

在这些日志中,文本文件中写入了“异常”标记,我想使用powershell在日志文本文件中查找所有可用的“异常”标记条目

我一直在尝试使用Powershell和以下cmdlet选项,但在使用
Select String
在文本文件中“Grep”出单词模式“Exception”之前,我无法获取gzip文件文本文件中的内容

Get-ChildItem '##Location of my log files directory###' | 
    Sort-Object LastWriteTime -Descending |
    Select-Object -First 1 |
    Get-ChildItem | ###Lists of my gzip log files###
问题:

有人能给我建议如何通过所有gzip日志文件枚举,以便获得所有日志文件中写入的“异常”标记条目。请以Powershell脚本或Powershell cmdlet的形式给出示例

真诚地


德里克

你想查看所有文件吗?因为现在您只查看最新的一个。我确实想查看所有文件,但重点是如何读取zip文件?您是否安装了类似7-zip的命令行压缩实用程序?请查看此文件以进行解压缩,我不明白您为什么将其标记为unix。Powershell是Windows的“功能”。祝你好运