teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

修正

2019/03/23 11:44

投稿

scsi
scsi

スコア2840

answer CHANGED
@@ -12,6 +12,7 @@
12
12
 
13
13
  queueid は任意の文字列なので \w+ や \S+ などの正規表現でマッチさせると抽出しやすいです。
14
14
  ```
15
+ perlでの抽出例
15
16
  cat maillog | perl -ne '{if(/postfix.*: (\w+): ((from|to)=\S+>),? /){$k{$1}{$3}=$2;}}END{foreach(sort keys %k){print "queueid=$_ $k{$_}{'from'} $k{$_}{'to'}\n";}}'
16
17
  queueid=5120C546D2E1 from=<bounce-000609027-000008849b84a6@fc5219.cuenote.jp> to=<recruit@example.com>
17
18
  queueid=B718A546D2E1 from=<dovecot-bounces@dovecot.org> to=<itml@example.com>
@@ -20,4 +21,4 @@
20
21
  \S+ (|) \w+ .* ,? などが正規表現です。
21
22
  ```
22
23
 
23
- 任意の文字列集計には必須ですね。
24
+ 任意の文字列をキーとした集計には必須ですね。