如何在Cygwin上安装/启用pcregrep?

del*_*ttg 5 cygwin pcregrep

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

使用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)
Run Code Online (Sandbox Code Playgroud)

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

$ man pcregrep
No manual entry for pcregrep
Run Code Online (Sandbox Code Playgroud)

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

$ pcregrep
-bash: pcregrep: command not found
Run Code Online (Sandbox Code Playgroud)

所以我的问题是: 在cygwin中我该怎么做才能允许我使用pcregrep?

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

Mva*_*est 6

您的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/下载。