[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Simple awk question



John Allen wrote:
kj wrote:
But I cannot find it in my awk book (O'Reilly's sed&awk).

I'm trying to make three columns out of a postfix mail log. Queue ID, From address, and remote server response for certain situations (it's already grepped down to that).

 awk '{print $7" "$6" "$17}'

$17 is the first word of the remote server response, I need to include everything from $17 onwards to the end of the line into the third field.

How do I specify that?

Use Perl :)
Thanks
--kj





I would love to - I'd have to learn it first :) I did figure it out,eventually. This is ugly, and most likely the wrong way to do it, but it works. It sorts it in order of the sender:

grep bounced /var/log/mail.log | awk '{printf "%s, %s ", $6,$7; { for (i=17; i<=NF; i=i+1) printf "%s ", $i } print "\n"}' | sed -e 's/:,/,/' -e 's/to=<//' -e 's/>,/,/' | grep -v ^$ | sort -k2 > /home/kj/bounces.csv


--kj


Reply to: