$1 == "#" { $1 = ""; $2 = ""; sub(/^[[:space:]]*/, ""); print "" print " " $0 "" print "" next } $2 == "select" { id = $1; $1 = ""; $2 = ""; options = "" for (i = 3; $i ~ /^@/ && i <= NF; ++i) { value = substr($i, 2) gsub(/_/, " ", value) options = options "" $i = "" } sub(/^[[:space:]]*/, "") if (NR % 2 == 0) { print "" } else { print "" } print " " id "" print " " $0 "" print " " print " " print " " print "" next } NF > 0 { id = $1; type = $2; $1 = ""; $2 = "" sub(/^[[:space:]]*/, "") if (NR % 2 == 0) { print "" } else { print "" } print " " id "" print " " $0 "" print " " print "" }