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

Re: awk usage question



On Don, 29 Mai 2003 at 20:19 (-0400), Kevin Coyner wrote:
> 
> I'm trying to filter a file from tcpdump (actually tethereal) using awk,
> but am stuck in one spot.
> 
> In words, what I'd like to do is:
> 
>     1.  only read lines with the word "Message" in it
>     2.  in lines with "Message", output everything to the right of the
>         word "Message".  This could be one word or twenty words.
> 
> Note that the word "Message", when it occurs in a line, always is in
> record number 7.


tethereal -r fileToRead | \
  nawk  ' $7 ~ /Message/ \
            { printf "%s ",  substr ($7, index ("Message") + 7);
              for (i = 8; i <= NF; i++) printf "%s ", $i;
              print "";
            } '

Jan



Reply to: