Results 1 to 10 of 10

Thread: Struggling with the "column" command, option -c

Threaded View

  1. #1
    Join Date
    May 2008
    United Kingdom
    Lubuntu 18.04 Bionic Beaver

    Question Struggling with the "column" command, option -c

    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:
    -c      Output is formatted for a display columns wide.
    Here is my test 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.
    column -t -s $'\t' -c ${COLUMNS} <<<"${LISTING}"
    Is there another solution that I can use? Or do I have to manually program this?
    Last edited by Paddy Landau; March 22nd, 2021 at 04:36 PM. Reason: Typing error
    Always make regular backups of your data (and test them).
    Visit Full Circle Magazine for beginners and seasoned Linux enthusiasts.

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts