Recently, I asked a question how to sort pairs of lines, and one of the answers suggested concatenating lines with
sed, like this:
cat file.txt | sed -n 'N;s/\n//;p' | sort -t";" -k43,43n | perl -F';' -ane '$,=";";print @F[0..13],"\n";print @F[14..$#F]'
which worked brilliantly, but now my problem generalized to sorting n-tupels of lines, which I can't figure out how to do with sed.
Everything I found was either for 2 lines or ALL lines, but I need n lines (where n is 5 at the moment, but a general way would be great).
Bonus points for a nice way of rewriting the
perl part to accomodate n lines, but the problem is really about the
I am also not hung on
sed specifically, so if you have a nice solution using a different command line tool, please post it.
Update: Example input (n == 3)
a1;b1;c1; n1;m1;l1; d1;e1;f1;g1 n2;m2;l2; a2;b2;c2; d2;e2;f2;g2