私のメール キューは現在、同じドメインの、大文字と小文字が混在したバウンス メッセージでいっぱいです。
exiqgrep
これらのメールをキューからフィルタリングするために使用してみましたが、コマンドでは大文字と小文字が区別されるようです。大文字と小文字を区別しない検索を実行する方法はありますか?
答え1
他の方が指摘したように、 exiqgrep プログラムは単なる Perl スクリプトです。 -r 関数 (受信者) に渡された生の値を取得し、それをパターン マッチで使用します。 パターン マッチは単純な$rcpt =~ /$opt{r}/
Perl テストで、指定されていないため、デフォルトのマッチでは大文字と小文字が区別されます。
Perl のすべての機能と同様に、TIMTOWTDI (There Is More Than One Way To Do It) です。上記の関数は -r に渡された値を削除またはサニタイズしないため、正規表現に ignore case 修飾子を埋め込むだけで済みます。シーケンスの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 }