I'm using the column command with the -c option to limit the width of the output in the terminal.
My problem is that it seems to ignore the -c option, so no matter what I put in it — a large or small number — it's completely ignored.
According to man column:
Code:
-c Output is formatted for a display columns wide.
Here is my test code:
Code:
LISTING=$'Col 1\tCol 2\tLong column three\tCol 4\nLong column 1\tcol 2\tcol 3\tcol 4\n'
column -t -s $'\t' -c 100 <<<"${LISTING}"
I can change 100 to 20, 200, whatever, and the output is always exactly the same. I can even put a non-number such as xyzzy, and it doesn't complain but still ignores it.
My problem is that the output for some listings exceeds the width of the terminal, so I wish to use ${COLUMNS} as the width, as follows, to prevent line-wrapping by truncating columns.
Code:
column -t -s $'\t' -c ${COLUMNS} <<<"${LISTING}"
Is there another solution that I can use? Or do I have to manually program this?
Bookmarks