0

Asked on another forum - no answer yet so I thought I would ask here. I had to escape the backslashes in the grep lines to make the backslash show up in this post.

I have this but grep is not returning the from line. It is something to do with the relay= part of the line. If I modify it to say relay=exampleXXX111.examplf.ex.examplf.com, it outputs the line just fine.

There are other ways to get this info, but I would like an explanation for this specific example.

echo "Apr 4 05:00:24 example sendmail[3365]: x3440OxC003366: from=, size=10181, class=0, nrcpts=1, msgid=<4E94014993C44528C502E32E3239E0B@example.XX.example.com>, proto=SMTP, daemon=MTA, relay=exampleXXX111.examplf.ex.example.com [10.100.10.10]" | grep -v "to=.*\.example\.com"

NO OUTPUT


echo "Apr 4 05:00:24 example sendmail[3365]: x3440OxC003366: from=, size=10181, class=0, nrcpts=1, msgid=<4E94014993C44528C502E32E3239E0B@example.XX.example.com>, proto=SMTP, daemon=MTA, relay=exampleXXX112.examplf.ex.examplf.com [10.100.10.10]" | grep -v "to=.*\.example\.com"

OUTPUT:

Apr 4 05:00:24 example sendmail[3365]: x3440OxC003366: from=, size=10181, class=0, nrcpts=1, msgid=<4E94014993C44528C502E32E3239E0B@example.XX.example.com>, proto=SMTP, daemon=MTA, relay=exampleXXX112.examplf.ex.examplf.com [10.100.10.10]

  • 1
    Please do some formatting according to the guidelines. – davidbaumann Apr 8 at 10:04
0

Your first example contains proto= SMTP, ... ex .example.com, so the grep condition is triggered and the -v will suppress the line.

Using grep -v '\sto=.*.example.com' should do the trick.

  • I did not see that, must have had my beer goggles on. Thank you for that. – Mikmikmikmik Apr 8 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.