Getting awk to print specific fields based on a variable
I am trying to make a table with awk, and it is printing every and the
matched variable data
virbr0 em0 TCP 27006 6400 22:09:58 25 Jun
em1 em0 UDP 12011 12070 22:31:51 01 Mar
em1 TCP 11257 11506 12:07:53 24 May
em2 UDP 10360 4693 19:44:36 16 Aug
em2 em2 UDP 6499 4805 05:20:48 27 Nov
OUT em0 em2 UDP 24927 5503 03:31:49 07 May
here's the statement:
awk -F";" -v ip="$AsArg" 'BEGIN {OFS="\t"};{if (ip==$5) dir="OUT"
};{printf "%3s\t %6s\t %6s\t %4s %8d %7d %10s\n", dir,$3,$4,$7,$8,$9,$1 }'
How do I get it to not print anything that doesn't match the ip variable's
value?
No comments:
Post a Comment