shell - Sed, awk, Perl or other for de-interleaving text file -


i relatively compact command perform line-by-line de-interleaving of text file, i.e

a1 a2 a3 a4 b1 b2 b3 b4 c1 c2 c3 c4 d1 d2 d3 d4 

maps to

a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3 a4 b4 c4 d4 

the interleaving depth should adjustable. lines not contain useful structure assist process, , example above toy example demonstration purposes. tool can use this?

sort can it!

$ sort -k1.2 your_file 

-k1.2 sorts first field starting 2nd character.

output:

a1 b1 c1 d1 a2 b2 c2 d2 a3 b3 c3 d3 a4 b4 c4 d4 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -