Also düster erinnere ich mich, vor Jahren mal nach so einem Spalten/Zeilentauscher gesucht zu haben in den coreutils.
Ob ich was gefunden habe, ob ich selbst was gebastelt habe, ich weiß es nicht mehr.
Mein erster Quick-n-Dirty-Versuch, Testdatei anlegen:
1
2
3
4
5
6
7
8
9
10
11
12 | echo "A:a
B:b
C:c
D:d
E:e" > columns.txt
cat columns.txt
A:a
B:b
C:c
D:d
E:e
|
Und dann laaaaaaaaaaaaaanger Einzeiler:
| (grep -o ".*:" columns.txt | pr --columns=5 - | head -n 6 | tail -n1; grep -o ":.*" columns.txt | pr --columns=5 - | head -n 6 | tail -n1 ) | sed 's/://g'
A B C D E
a b c d e
|
Ich kann mich nicht erinnern je pr benutzt zu haben, wahrscheinlich ist meine Verwendung vollkommener Quatsch. ☺
Vielleicht sind column und colrm doch nützlichere Werkzeuge.
Aus der Manpage column:
NAME
column — columnate lists
SYNOPSIS
column [-entx] [-c columns] [-s sep] [file ...]
DESCRIPTION
The column utility formats its input into multiple columns. Rows are filled before columns. Input is taken from file operands, or, by default, from
the standard input. Empty lines are ignored unless the -e option is used.