I want to filter some of the mail IDs returned by
mailq (Postfix). However, the format is not very "grep-friendly", since the information for a single mail spans multiple lines:
9F701869D2 1356 Mon Aug 23 12:13:43 some@sender (host some.host[126.96.36.199] said: 450 4.1.1 some error message) some@recipient 9437586CF4 3153 Sat Aug 21 09:36:40 firstname.lastname@example.org (host some.host[188.8.131.52] said: 450 4.1.1 some error message) email@example.com
What's the easiest way to get, for example, all mail IDs where some particular error code occurred? Maybe by removing the (single) newlines, then
greping and then
cuting? Or by using some other, more suitable tool?
Please explain your answer. My main interest is not a copy-and-paste solution for my current problem (filtering by error code), but rather understanding how to easily parse such multi-line output.