exiqgrep 不區分大小寫?

exiqgrep 不區分大小寫?

我的郵件佇列目前充滿了同一網域的退回郵件,但大小寫混合。

我嘗試使用exiqgrep從佇列中過濾這些郵件,但該命令似乎區分大小寫。有什麼方法可以執行不區分大小寫的搜尋嗎?

答案1

正如另一位先生指出的那樣,exiqgrep 程式只是一個 perl 腳本。它會取得傳遞給 -r 函數(接收者)的原始值並將其用於模式匹配。模式匹配是一個簡單的$rcpt =~ /$opt{r}/Perl 測試,預設匹配(由於未指定)區分大小寫。

與 Perl 的所有事物一樣,TIMTOWTDI(有不止一種方法可以做到這一點)。由於上面的函數不會刪除或清理傳遞給 -r 的值,因此您可以簡單地在正規表示式中嵌入忽略大小寫修飾符。perldoc perlre有關該(?MODIFIERS:...)序列如何工作的更多詳細信息,請參閱 參考資料。

下面是一個範例,其中我展示了混合大小寫搜尋找不到我正在尋找的網域,但透過使用內聯標誌修飾符作為搜尋字詞的一部分,它找到了它。

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]

您的搜尋將是類似的,例如:

(?i:@thedomainyouseek.com)

答案2

線上說明頁不顯示此類選項,但該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 }

相關內容