Column
From BITS wiki
Align columns of text
suggests : transpose
[ Main_Page ]
Utility to present columnar data nicely padded with spaces. A nice complement to transpose or any other text grabbing tabular results.
# man column SYNOPSIS column [-tx] [-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. The options are as follows: -c Output is formatted for a display columns wide. -s Specify a set of characters to be used to delimit columns for the -t option. -t Determine the number of columns the input contains and create a table. Columns are delimited with whitespace, by default, or with the characters supplied using the -s option. Useful for pretty-printing displays. -x Fill columns before filling rows. BUG Input lines are limited to LINE_MAX (2048) bytes in length.
# create example data with one missing value echo 'X column1 column2 column3 row1 0 1 2 row2 3 4 5 row3 6 7 8 row4 9 11' > ex.txt # !!! the delimiter in this file is 'space' and not tab # reformat with column column -t ex.txt X column1 column2 column3 row1 0 1 2 row2 3 4 5 row3 6 7 8 row4 9 11 # we lost the missing spot, lets get it back column -t -n ex.txt X column1 column2 column3 row1 0 1 2 row2 3 4 5 row3 6 7 8 row4 9 11 # additional spaces have been added to make nicer columns # try 'man column' for more options # now replace spaces by tabs and transpose lines and columns (pivot | rotate) tr "\ " "\t" < ex.txt | transpose -t X row1 row2 row3 row4 column1 0 3 6 9 column2 1 4 7 column3 2 5 8 11 # try 'transpose --help' and read the transpose page
[ Main_Page ]