E.g. I have a file (produced with echo -e "var1\tvar2\t\var3\tvar4" > foo
) that are output as:
$ cat foo
case elems meshing nlsys
uniform 2350 0.076662 2.78
non-conformal 348 0.013332 0.55
scale 318 0.013333 0.44
smarter 504 0.016666 0.64
submodel 360 .009999 0.40
unstruct-quad 640 0.019999 0.80
unstruct-tri 1484 0.01 0.88
I'd prefer the output like this (here I used vim
and :set tabstop=14
):
case elems meshing nlsys
uniform 2350 0.076662 2.78
non-conformal 348 0.013332 0.55
scale 318 0.013333 0.44
smarter 504 0.016666 0.64
submodel 360 .009999 0.40
unstruct-quad 640 0.019999 0.80
unstruct-tri 1484 0.01 0.88
I can get the same functionality with cat
if I use $ tabs=15
in bash (see this question). Is there a program that does this kind of formatting automatically? I don't want to experiment with the tabs
value before cat
ing a file.
-s $'\t'
(not found in every column implementations though) in case some of the fields contain spaces. – Stéphane Chazelas Sep 11 '12 at 15:07-s '\t'
don't work directly whereas-s '@'
or any other character works directly. What is the role of$
that makes this happen in-s $'\t'
? – Rakholiya Jenish Jul 07 '15 at 06:47$'\t'
means tab character. New line is$'\n'
and so on. – Manwe Sep 24 '15 at 10:31-t
argument mean? My man page has no info on it. What is-t foo
? – bodacydo Dec 05 '15 at 02:25-t
flag. Thefoo
on the command line is the input file, if it is omitted, standard in will be used instead. In order to determine correct column widths, column will buffer the whole input before returning the result. – Thor Dec 06 '15 at 07:39column -ts: /etc/passwd
. Looks cool! – kyb Sep 01 '18 at 16:56-n
, i.e. avoid merging multiple adjacent delimiters – Thor Sep 04 '18 at 10:19