Grep out ONLY subject from maillog

I have the following entries in maillog. I need to grep out only the subject part from the following entries. Maillog contain following entries.

2013-11-14 03:30:02 [441847] 1Vgnd4-001qwZ-36 <= user@domain.com U=user P=local S=9797  id=cd3732bbd0fbda5cb16384bb7d5b465d@localhost.localdomain T="Subject Subject  Subject" from <user@domain.com> for  anothermail@newdomain.com

After applying the sed/awk, we should get result as follows.

Subject Subject  Subject

To summarize, the pattern, after T= should be printed.

Eg:
T="sub sub sub"
Should print
sub sub sub

try:

sed -n 's/.*T="\([^"]*\)".*/\1/p' infile

or

awk -F\" '/T=/{print $2}' infile
1 Like
echo '2013-11-14 03:30:02 [441847] 1Vgnd4-001qwZ-36 <= user@domain.com U=user P=local S=9797  
id=cd3732bbd0fbda5cb16384bb7d5b465d@localhost.localdomain T="Subject Subject  Subject" 
from <user@domain.com> for  anothermail@newdomain.com' | perl -nle 'print $1 if (/T="(.+?)"/)' 
1 Like

Another awk

awk '/T=/ {f=NR} f&&NR-1==f' RS=\" file
Subject Subject  Subject

or this:

awk '/T=/ {getline;print}' RS=\" file
Subject Subject  Subject

@Chubler_XL
This awk -F\" '/T=/{print $2}' infile is not very robust.
It just print second field (using " as FS ) if the line contain T= . So if other filed has quotes this will fail.