내 메일 대기열은 현재 동일한 도메인에 대한 반송 메시지로 가득 차 있지만 대소문자가 혼합되어 있습니다.
내 대기열에서 이러한 메일을 필터링하기 위해 을(를 ) 사용해 보았지만 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 }