#!/mit/gnu/bin/gawk -f BEGIN { mode = 0 } NF == 0 { next } $0 == "% BOX" { mode = 1; next } $0 == "% OVAL" { mode = 2; next } $0 == "% POLY/OPEN-SPLINE" { mode = 3; next } $0 == "% POLYGON/CLOSED-SPLINE" { mode = 4; next } $1 == "%" { mode = 0; print; next } mode == 0 { gsub( / */, " "); sub(/^ /, ""); print; next } $0 == "gsave" || $0 == "grestore" || $2 == "setmiterlimit" { next } { gsub( / */, " "); sub(/^ /, ""); print }