Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

cut two columns from string of text

  • 04-07-2006 12:09pm
    #1
    Closed Accounts Posts: 667 ✭✭✭


    Hi,

    Basically trying to cut the email address and the status code from test as in below

    Jul 4 09:33:26 obeml1 postfix/smtp[16575]: [ID 197553 mail.info] AC9A13C743: to=<bookings@xxxx.com>, relay=192.168.1.14[192.168.1.14], delay=1, status=bounced (host 192.168.1.14[192.168.1.14] said: 550 No such recipient (in reply to RCPT TO command))

    I can get the address via

    grep "bounced" /opt/postfixlogs/postfix.log|cut -f2 -d'<' |cut -f1 -d'>'

    however i also want in the same output the code so need the "said: xxx" - in this case a 550

    I cant use just awk and clumn numbers as the output lines are often differing lenth and order eg,

    Jul 4 00:59:39 obeml1 postfix/smtp[24961]: [ID 197553 mail.info] 3801B3C765: to=<LIAMxxx@YAHOO.COM>, relay=mx1.mail.YAHOO.COM[4.79.181.14], delay=1, s
    tatus=bounced (host mx1.mail.YAHOO.COM[4.79.181.14] said: 554 delivery error: dd This user doesn't have a yahoo.com account (liamcahilldublin@yahoo.com) [-5] -
    mta216.mail.mud.yahoo.com (in reply to end of DATA command))

    ABOVE IS SINGLE LINE ALTHOUGH DOENT LOOK IT

    but i still only need the address and the "said xxx" code

    Nay help much appreciated.


    Would like eventually output like


    address code
    loz@here 550
    blah@there 452
    blah2@here 556


    etc

    Thanks

    Loz


Comments

  • Registered Users, Registered Users 2 Posts: 273 ✭✭electrofelix


    sed is your best friend here.
    grep "status=bounced" /opt/postfixlogs/postfix.log | \
    sed -e 's:[^<]*<\([^@]*@[^>]*\)>.*said\: \([0-9]\+\).*:\1\t\2:'
    

    You could still use awk and do regex matching with that as well. Try not to forget that awk can do a lot more than just column matching.

    \ after the pipe comand is to allow command to continue to the next line in case you weren't aware of that. So remove it if your put the entire command on one line.


Advertisement