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

8
我尝试使用pcregrep,按照这个SO问题的顶部答案,在Cygwin上运行。我的环境是Win7 64位,运行Cygwin V 1.7.20(0.266/5/3)。
使用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的指示,但是在Cygwin安装中似乎没有patch。我通过以下两个同样问题的SO问题找到了这篇教程:SO问题1SO问题2。为了让它们出现在相关问题部分,我引用了它们。这个man手册显示它可以存在于Cygwin中,但是尝试运行它的man页面会导致:
$ man pcregrep
No manual entry for pcregrep

看起来我的Cygwin安装中已经存在pcregrep的库,但我不知道如何编译/提取/启用它们以获得访问该工具的权限。当我尝试运行它时,Bash会返回标准的“命令未找到”响应。

$ pcregrep
-bash: pcregrep: command not found

我的问题是:在cygwin中,我该怎么做才能使用pcregrep?

我不确定该如何继续,我有数万个日志文件需要处理,我需要找到三行相关的数据,它们之间的行数、这些行的字符串构成以及位于它们上面的“标题”行告诉我正确的传感器类型信息(单个日志中可能有多个传感器数据,我必须使用特定的传感器数据集)。如果我无法安装pcregrep(似乎非常适合此工作),我将提出带有数据的根本问题。

1个回答

7
您的cygcheck -p查询显示这三个软件包中都提到了pcregrep。在线软件包浏览器(online package browser)确认在pcre软件包中提供了pcregrep.exe二进制文件,您无需编译任何内容。
使用Cygwin安装程序setup-x86.exe(适用于32位Cygwin)或setup-x86_64.exe(适用于64位Cygwin),您可能已经首先使用它来安装Cygwin,以安装该软件包:当您到达“选择软件包”步骤时,在文本类别中找到pcre,单击新列中的循环图标,直到出现版本号,然后完成安装。如果您不再拥有安装程序,则可以从https://cygwin.com/下载它。

谢谢您的回复,等我有时间了就去看一下。我已经用不同的方法解决了原来的问题。 - delliottg
1
我确实有这个期望。昨天我想使用 pcregrep,但是这个被点赞但未回答的问题让我担心它可能会很困难。结果证明它非常可行,所以我决定为下一个遇到这个问题的人记录下来。 - MvanGeest

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接