2

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.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
René Nyffenegger
  • 2,201
  • 2
  • 23
  • 28
  • 2
    `expand` from GNU `coreutils` converts tabs to spaces. There are many other ways, f.i. using Vim. – Satō Katsura Feb 16 '17 at 06:26
  • 1
    You did see the `-s` option in the manpage, did you? – Murphy Feb 16 '17 at 08: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 09: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 Answers1

3

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

column -c 60 file.txt | expand
Bob Eager
  • 3,520
  • 2
  • 14
  • 29