bash - Joining lines, modulo the number of records -
say stream x*n lines long, x number of records , n number of columns per record, , output column-wise. example, x=2, n=3:
1 2 alice bob london new york how can join every line, modulo number of records, columns:
1 alice london 2 bob new york if use paste, n -s, transposed output. use split, -l option equal n, recombine pieces afterwards paste, i'd within stream without spitting out temporary files on place.
is there "easy" solution (i.e., rather invoking awk)? i'm thinking there may magic join solution, can't see it...
edit example, when x=5 , n=3:
1 2 3 4 5 b c d e alpha beta gamma delta epsilon expected output:
1 alpha 2 b beta 3 c gamma 4 d delta 5 e epsilon
you looking pr "columnate" stream:
pr -t -s$'\t' -3 <<'end_stream' 1 2 alice bob london new york end_stream 1 alice london 2 bob new york pr in coreutils.
Comments
Post a Comment