Skip to main content
added 110 characters in body
Source Link
Digital Trauma
  • 8.9k
  • 2
  • 25
  • 42

If you have the rs (reshape) utility available, you can do the following:

rs -Tzc: < input.txt

This gives the output format exactly as specified in the question, even down to the dynamic column widths.

  • -T Transposes the input data
  • -z sizes the columns appropriately from the max in each column
  • -c: uses colon as the input field separator

This works for arbitrarily sized tables, e.g.:

$ echo "Name:Alice:Bob:Carol
Age:12:34:56
Eyecolour:Brown:Black:Blue" | rs -Tzc: 
Name   Age  Eyecolour
Alice  12   Brown
Bob    34   Black
Carol  56   Blue
$ 

rs is available by default on OS X (and likely other BSD machines). It can be installed on Ubuntu (and debian family) with:

sudo apt-get install rs

If you have the rs (reshape) utility available, you can do the following:

rs -Tzc: < input.txt
  • -T Transposes the input data
  • -z sizes the columns appropriately from the max in each column
  • -c: uses colon as the input field separator

This works for arbitrarily sized tables, e.g.:

$ echo "Name:Alice:Bob:Carol
Age:12:34:56
Eyecolour:Brown:Black:Blue" | rs -Tzc: 
Name   Age  Eyecolour
Alice  12   Brown
Bob    34   Black
Carol  56   Blue
$ 

rs is available by default on OS X (and likely other BSD machines). It can be installed on Ubuntu (and debian family) with:

sudo apt-get install rs

If you have the rs (reshape) utility available, you can do the following:

rs -Tzc: < input.txt

This gives the output format exactly as specified in the question, even down to the dynamic column widths.

  • -T Transposes the input data
  • -z sizes the columns appropriately from the max in each column
  • -c: uses colon as the input field separator

This works for arbitrarily sized tables, e.g.:

$ echo "Name:Alice:Bob:Carol
Age:12:34:56
Eyecolour:Brown:Black:Blue" | rs -Tzc: 
Name   Age  Eyecolour
Alice  12   Brown
Bob    34   Black
Carol  56   Blue
$ 

rs is available by default on OS X (and likely other BSD machines). It can be installed on Ubuntu (and debian family) with:

sudo apt-get install rs
added 407 characters in body
Source Link
Digital Trauma
  • 8.9k
  • 2
  • 25
  • 42

If you have the rs (reshape) utility available, you can do the following:

rs -Tzc: < input.txt
  • -T Transposes the input data
  • -z sizes the columns appropriately from the max in each column
  • -c: uses colon as the input field separator

This works for arbitrarily sized tables, e.g.:

$ echo "Name:Alice:Bob:Carol
Age:12:34:56
Eyecolour:Brown:Black:Blue" | rs -Tzc: 
Name   Age  Eyecolour
Alice  12   Brown
Bob    34   Black
Carol  56   Blue
$ 

rs is available by default on OS X (and likely other BSD machines). It can be installed on Ubuntu (and debian family) with:

sudo apt-get install rs

If you have the rs (reshape) utility available, you can do the following:

rs -Tzc: < input.txt

rs is available by default on OS X (and likely other BSD machines). It can be installed on Ubuntu (and debian family) with:

sudo apt-get install rs

If you have the rs (reshape) utility available, you can do the following:

rs -Tzc: < input.txt
  • -T Transposes the input data
  • -z sizes the columns appropriately from the max in each column
  • -c: uses colon as the input field separator

This works for arbitrarily sized tables, e.g.:

$ echo "Name:Alice:Bob:Carol
Age:12:34:56
Eyecolour:Brown:Black:Blue" | rs -Tzc: 
Name   Age  Eyecolour
Alice  12   Brown
Bob    34   Black
Carol  56   Blue
$ 

rs is available by default on OS X (and likely other BSD machines). It can be installed on Ubuntu (and debian family) with:

sudo apt-get install rs
Source Link
Digital Trauma
  • 8.9k
  • 2
  • 25
  • 42

If you have the rs (reshape) utility available, you can do the following:

rs -Tzc: < input.txt

rs is available by default on OS X (and likely other BSD machines). It can be installed on Ubuntu (and debian family) with:

sudo apt-get install rs