1

I'd like to tabularize a file with the column command:

$ column -c 60 file.txt

The output is nice on the screen, but unusable for my purposes because the items are seperated by tabs. for further processing, I need them as whitespace.

Of course, I cannot just replace one tab with one space because this would destroy the left-alignment of the 2nd, 3rd etc column.

  • 2
    expand from GNU coreutils converts tabs to spaces. There are many other ways, f.i. using Vim. – Satō Katsura Feb 16 '17 at 6:26
  • 1
    You did see the -s option in the manpage, did you? – Murphy Feb 16 '17 at 8:58
  • Yes, I did. In mine, it says Specify a set of characters to be used to delimit columns for the -t option.. – René Nyffenegger Feb 16 '17 at 9:37
  • 1
    As you didn't give any examples of input and expected output, this may be what you need, or not. For me, column -t -s ' ' works insofar as it uses spaces instead of tabs as column separators. As the manpage describes: "-t [...] Useful for pretty-printing displays.". – Murphy Feb 16 '17 at 10:12
  • Yes, -s works well with -t but I am not asking for input seperators, but for output seperators. Apologies if my question was not clear. – René Nyffenegger Feb 16 '17 at 14:39
1

Surely this is as simple as mentioned in the first comment. But here it is, spelled out:

column -c 60 file.txt | expand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.