BEGIN {top = 0; bottom = 0; left = 0; right = 0; } /top/{top = $3;} /bottom/{bottom = $3;} /left/{left = $3;} /right/{right = $3;} END {printf ("-top %d -bottom -%d -left %d -right -%d",top,++bottom,left,++right); }