I want to combine every even-numbered line with the line above it. Something like:
Line one,csv,csv,csv Line two,csv,csv Line three,csv,csv,csv,csv Line four,csv
The result should look like this:
Line one,csv,csv,csv,Line two,csv,csv Line three,csv,csv,csv,csv,Line four,csv
Any ideas how to achieve that in either Perl or sed/awk?
here it is, with sed:
sed '$!N;s/\n/,/'
and with awk:
awk '{if (e) {print p","$0;} else {p=$0;} e=!e;}'
or
awk 'NR%2==0 {print p","$0;} NR%2 {p=$0;}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With