8

我正在尝试使用 Cygwin 上这个 SO 问题的最佳答案中指定的 pcregrep 。我的环境是运行 Cygwin V 1.7.20(0.266/5/3) 的 Win7 64 位。

使用cygcheck -p pcregrep我得到:

Found 6 matches for pcregrep
libpcre-devel-8.37-1 - libpcre-devel: Perl Compatible Regular Expressions library development (installed binaries and support files)
libpcre-devel-8.37-2 - libpcre-devel: Perl Compatible Regular Expressions library development (installed binaries and support files)
pcre-debuginfo-8.37-1 - pcre-debuginfo: Debug info for pcre (installed binaries and support files)
pcre-debuginfo-8.37-2 - pcre-debuginfo: Debug info for pcre (installed binaries and support files)
pcre-8.37-1 - pcre: Perl Compatible Regular Expressions utilities (installed binaries and support files)
pcre-8.37-2 - pcre: Perl Compatible Regular Expressions utilities (installed binaries and support files)

我尝试使用本教程中找到的安装 pcregrep 的说明,但patch似乎不是 cygwin 安装的一部分。本教程是通过这两个与我的思路相同的 SO 问题找到的: SO Question 1SO Question 2,引用它们,以便它们出现在相关问题部分。 此手册页显示它可以存在于 cygwin 中,但尝试为其运行手册页会导致:

$ man pcregrep
No manual entry for pcregrep

pcregrep 的库似乎存在于我的 cygwin 安装中,但我不知道如何编译/提取/使它们能够访问该实用程序。当我尝试运行它时,我得到了来自 bash 的未找到标准命令的响应:

$ pcregrep
-bash: pcregrep: command not found

所以我的问题是: 我在 cygwin 中做什么才能让我使用 pcregrep?

我不知道如何继续,我有数以万计的日志文件要处理,我需要能够通过其中两个之间的行数找到与每个相关的三行,构成这些行中的字符串和它们上方的“标题”行告诉我正确的传感器类型信息如下(单个日志中可以有多个传感器数据,我必须使用一组特定的传感器数据)。如果我不知道如何安装 pcregrep(这似乎非常适合这项工作),我会用数据询问基本问题。

4

1 回答 1

7

您的cygcheck -p查询表明这pcregrep三个包中提到了这一点。在线包浏览器确认包中有可用的pcregrep.exe 二进制文件pcre:您无需编译任何内容。

使用 Cygwin 安装程序,setup-x86.exe(对于 32 位 Cygwin)或setup-x86_64.exe(对于 64 位 Cygwin),您可能首先用来安装 Cygwin,安装包:当您进入“选择包" 步骤,pcre在 Text 类别中找到,单击 New 列中的循环图标,直到出现版本号,然后完成安装。如果您不再拥有安装程序,您可以从https://cygwin.com/下载它。

于 2016-01-30T19:08:18.563 回答