# Intended purpose: Pipe birdc s p all into this script - line by line / protocol by protocol # initialize variable BEGIN { if (!pref) { pref="^p_"; } proto=""; } # default output for birdc, filter $1=="BIRD" || $1=="Name" { next } # if line begins with dn and is a BGP line $0 ~ pref && $2=="BGP" { proto=$1 print "" $1 "" $2 "" $4 ""; next } # for every other line "starting" a protocol /^[a-zA-Z]/ { # reset proto proto="" next }