here\'s my situation: I had a big text file that I wanted to pull certain information from. I used sed to pull all the relevant information based on regexp\'s, but each \"piece\
Without special-casing field 3, easy.
awk '
!/^,/ { if (NR > 1) print x ; x = $0 }
/^,/ { x = x OFS $0 }
END { if (NR) print x }
'
With, more complex but still not too hard.
awk '
!/^,/ { if (n && n < 3) print x ; x = $0 ; n = 1 }
/^,/ { if (++n > 2) { print x, $0 } else { x = x OFS $0 } }
END { if (n && n < 3) print x }
'