Let's say I have a file orders.txt
which contains something like:
# Description Amount Price Sum
1 Beermat 1000 0,01€ 10€
2 Glass 100 1€ 100€
3 Long description 1 10€ 10€
4 An even longer description 1 10€ 10€
5 An extra long description, for real! 1 10€ 10€
6 An extra long description, almost max. length 1 10€ 10€
7 Long description for some really fancy product and unfortunately this description is too long to fit into one line - bad luck! 1 10€ 10€
8 This line isn’t shown afterwards 1 1€ 1€
Where the columns are separated with a tabstop a.k.a. \t
Usually I format these things with a little tool column -ts $'\t' order.txt
which results in something like:
# Description Amount Price Sum
1 Beermat 1000 0,01€ 10€
2 Glass 100 1€ 100€
3 Long description 1 10€ 10€
4 An even longer description 1 10€ 10€
5 An extra long description, for real! 1 10€ 10€
6 An extra long description, almost max. length 1 10€ 10€
This works fine as long as one line doesn't exceed the line width of your terminal window. So in case of line #7 this tool outputs a column: line too long
and exits.
What I'm looking for is a solution to generate me an output like this one:
# Description Amount Price Sum
1 Beermat 1000 0,01€ 10€
2 Glass 100 1€ 100€
3 Long description 1 10€ 10€
4 An even longer description 1 10€ 10€
5 An extra long description, for real! 1 10€ 10€
6 An extra long description, almost max. length 1 10€ 10€
7 Long description for some really fancy product 1 10€ 10€
and unfortunately this description is too long
to fit into one line - bad luck!
8 This line isn’t shown afterwards 1 1€ 1€