不区分大小写exiqgrep?

我的邮件队列当前充满了同一个域的反弹邮件,但是大小写混合。

我试图使用exiqgrep从我的队列中过滤这些邮件,但似乎命令是区分大小写的。 有没有办法执行不区分大小写的search?

正如另一位先生指出的那样,exiqgrep程序只是一个perl脚本。 它将传递给-r函数(收件人)的原始值用于模式匹配。 模式匹配是一个简单的$rcpt =~ /$opt{r}/ perltesting,默认匹配,因为没有指定,区分大小写。

和perl的所有东西一样,TIMTOWTDI(还有更多的方法可以做到这一点)。 由于上面的函数没有去除或清理传递给-r的值,所以可以简单地在正则expression式中embedded一个忽略大小写修饰符。 有关(?MODIFIERS:...)序列如何工作的更多详细信息,请参阅perldoc perlre

下面是一个示例,其中显示混合大小写search未find要查找的域,但通过使用内联标志修饰符作为search项的一部分,可以find它。

 OVZ-CentOS58[root@ivwm51 ~]# exiqgrep -r '[email protected]' 26h 4.0K 1VGRud-0001sm-P1 <> *** frozen *** [email protected] OVZ-CentOS58[root@ivwm51 ~]# exiqgrep -r '[email protected]' OVZ-CentOS58[root@ivwm51 ~]# exiqgrep -r '(?i:[email protected])' 26h 4.0K 1VGRud-0001sm-P1 <> *** frozen *** [email protected] 

您的search将类似,如下所示:

 (?i:@thedomainyouseek.com) 

联机帮助页不显示这样的选项,但exiqgrep实用程序是一个perl脚本,您可以根据自己的需要修改它的源代码:

 114 sub selection() { 115 foreach my $msg (keys(%id)) { 116 if ($opt{f}) { 117 # Match sender address 118 next unless ($id{$msg}{from} =~ /$opt{f}/); # here 119 } 120 if ($opt{r}) { 121 # Match any recipient address 122 my $match = 0; 123 foreach my $rcpt (@{$id{$msg}{rcpt}}) { 124 $match++ if ($rcpt =~ /$opt{r}/); # or here 125 } 126 next unless ($match); 127 } 128 if ($opt{s}) { 129 # Match against the size string. 130 next unless ($id{$msg}{size} =~ /$opt{s}/); 131 } 132 if ($opt{y}) { 133 # Match younger than 134 next unless ($id{$msg}{ages} $opt{o}); 139 } 140 if ($opt{z}) { 141 # Exclude non frozen 142 next unless ($id{$msg}{frozen}); 143 } 144 if ($opt{x}) { 145 # Exclude frozen 146 next if ($id{$msg}{frozen}); 147 } 148 # Here's what we do to select the record. 149 # Should only get this far if the message passed all of 150 # the active tests. 151 $id{$msg}{d} = 1; 152 # Increment match counter. 153 $mcount++; 154 } 155 }