File: column.1

package info (click to toggle)
util-linux 2.42~rc1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 101,864 kB
  • sloc: ansic: 185,733; sh: 24,450; yacc: 1,288; makefile: 534; xml: 422; python: 316; lex: 89; ruby: 75; csh: 37; exp: 19; sed: 16; perl: 15; sql: 9
file content (513 lines) | stat: -rw-r--r-- 15,402 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
'\" t
.\"     Title: column
.\"    Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.20
.\"      Date: 2026-02-25
.\"    Manual: User Commands
.\"    Source: util-linux 2.42-rc1
.\"  Language: English
.\"
.TH "COLUMN" "1" "2026-02-25" "util\-linux 2.42\-rc1" "User Commands"
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
.  mso www.tmac
.  am URL
.    ad l
.  .
.  am MTO
.    ad l
.  .
.  LINKSTYLE blue R < >
.\}
.SH "NAME"
column \- columnate lists
.SH "SYNOPSIS"
.sp
\fBcolumn\fP [options] [\fIfile\fP ...]
.SH "DESCRIPTION"
.sp
The \fBcolumn\fP utility formats its input into multiple columns. It supports three modes:
.sp
\fBfill columns before rows\fP
.RS 4
This is the default mode (required for backwards compatibility).
.RE
.sp
\fBfill rows before columns\fP
.RS 4
This mode is enabled with the \fB\-x, \-\-fillrows\fP option.
.RE
.sp
\fBcreate a table\fP
.RS 4
Determine the number of columns the input contains and create a table.
This mode is enabled with the \fB\-t\fP/\fB\-\-table\fP option.
Output is aligned to the terminal width in interactive mode, and to 80 columns
in non\-interactive mode (see \fB\-\-output\-width\fP for more details).
Custom formatting can be applied by using various \fB\-\-table\-\fP* options.
.RE
.sp
Input is taken from \fIfile\fP, or otherwise from standard input. Empty lines are ignored and all invalid multibyte sequences are encoded with the x<hex> convention.
.SH "OPTIONS"
.sp
The argument \fIcolumns\fP, for the \fB\-\-table\-\fP* options below, is a comma\-separated list
of user\-supplied names defined with \fB\-\-table\-columns\fP \fIname1\fP\fB,\fP\fIname2\fP\fB,\fP...,
or indices of columns as they appear in the input, beginning with 1,
or names defined through a \fB\-\-table\-column\fP attribute.
It\(cqs possible to mix names and indices. The special placeholder \*(Aq0\*(Aq (e.g. \-R0) may
be used to specify all columns and \*(Aq\-1\*(Aq (e.g. \-R \-1) to specify the last visible column.
It\(cqs possible to use ranges like \*(Aq1\-5\*(Aq when addressing columns by indices.
.sp
\fB\-J, \-\-json\fP
.RS 4
Use JSON output format to print the table. The option \fB\-\-table\-columns\fP is required and the option \fB\-\-table\-name\fP is recommended.
.RE
.sp
\fB\-c, \-\-output\-width\fP \fIwidth\fP
.RS 4
Output is formatted to a width specified as a number of characters.
Note that input longer than \fIwidth\fP is not truncated by default.
The default is the terminal width in interactive mode, and 80 columns in non\-interactive mode.
The column headers are never truncated.
.sp
The placeholder \fBunlimited\fP (or \fB0\fP) can be used to prevent restricting the output width.
This is recommended when redirecting output to a file.
.sp
(The original long name of this option was \fB\-\-columns\fP; this name is deprecated since v2.30.)
.RE
.sp
\fB\-d, \-\-table\-noheadings\fP
.RS 4
Omit printing the header. This option allows having user\-supplied column names on the command line, but keeps the header hidden when printing the table.
.RE
.sp
\fB\-o, \-\-output\-separator\fP \fIstring\fP
.RS 4
Column delimiter for table output (default is two spaces).
.RE
.sp
\fB\-s, \-\-input\-separator, \-\-separator\fP \fIseparators\fP
.RS 4
Possible input\-item delimiters (default is whitespace).
.RE
.sp
\fB\-S, \-\-use\-spaces\fP \fInumber\fP
.RS 4
When not in table mode, use spaces instead of tabulators to align the columns. This option specifies the minimum number of spaces that separate two columns.
.RE
.sp
\fB\-t, \-\-table\fP
.RS 4
Determine the number of columns the input contains and create a table. Columns are by default delimited with whitespace, or with characters supplied using the \fB\-\-output\-separator\fP option. Table output is useful for pretty\-printing.
.RE
.sp
\fB\-\-table\-colorscheme\fP \fIname\fP
.RS 4
Specifies color scheme. The default name is "column". For more details see the \fBCOLORS\fP section.
.RE
.sp
\fB\-C, \-\-table\-column\fP \fIattributes\fP
.RS 4
Define a column with a comma\-separated list of attributes.
This option can be used more than once, every use defines a single column.
Attributes replace some of the \fB\-\-table\-\fP* options: for example,
\fB\-\-table\-column name=FOO,right\fP defines a column where text is aligned to the right.
The option is mutually exclusive with \fB\-N\fP/\fB\-\-table\-columns\fP.
.sp
Supported attributes are:
.sp
\fBname=\fP\fIstring\fP
.RS 4
Column name.
.RE
.sp
\fBtrunc\fP
.RS 4
Truncate column text when necessary. The same as \fB\-\-table\-truncate\fP.
.RE
.sp
\fBtree\fP
.RS 4
Use this column for tree\-like output. See \fB\-\-tree\fP for more details.
.RE
.sp
\fBright\fP
.RS 4
Right align text. The same as \fB\-\-table\-right\fP.
.RE
.sp
\fBwidth=\fP\fInumber\fP
.RS 4
Column width. It\(cqs used only as a hint. To enforce it, specify the \fBstrictwidth\fP attribute
as well.
.RE
.sp
\fBstrictwidth\fP
.RS 4
Strictly follow the \fBwidth=\fP setting.
.RE
.sp
\fBnoextremes\fP
.RS 4
Ignore unusually long content width. See \fB\-\-table\-noextreme\fP for more details.
.RE
.sp
\fBhidden\fP
.RS 4
Don\(cqt print the column. See \fB\-\-table\-hide\fP for more details.
.RE
.sp
\fBwrap\fP
.RS 4
Allow using a multi\-line cell for long text if necessary. See \fB\-\-table\-wrap\fP for more details.
.RE
.sp
\fBwrapnl\fP
.RS 4
Wrap at newline characters; newlines in cell data are treated as line breaks.
.RE
.sp
\fBwrapzero\fP
.RS 4
Wrap at zero (NUL) characters in cell data.
.RE
.sp
\fBjson=\fP\fItype\fP
.RS 4
Define the column type for JSON output. Supported types are \fBstring\fP, \fBnumber\fP, \fBfloat\fP,
\fBarray\-string\fP, \fBarray\-number\fP and \fBboolean\fP.
.RE
.sp
\fBcolor=\fP\fIname\fP
.RS 4
Define the column color for output on the terminal. The \fIname\fP is a color name
(black, blink, blue, bold, brown, cyan, darkgray, gray, green, halfbright,
lightblue, lightcyan, lightgray, lightgreen, lightmagenta, lightred, magenta,
red, reset, reverse, and yellow) or ANSI color sequence number(s) separated by
a semicolon, but without the \*(AqESC[\*(Aq prefix and \*(Aqm\*(Aq suffix. For example, "37;41"
defines sequences for a red background and white foreground. For more details
see the \fBCOLORS\fP section.
.RE
.sp
\fBcolorkey=\fP\fIname\fP
.RS 4
Addresses color as defined in the color scheme. See \fB\-\-table\-colorscheme\fP.
.RE
.sp
\fBheadercolor=\fP\fIname\fP
.RS 4
Like \fBcolor=\fP, but define the color for column header only.
.RE
.sp
\fBheadercolorkey=\fP\fIname\fP
.RS 4
Addresses color for header as defined in the color scheme. See \fB\-\-table\-colorscheme\fP.
.RE
.RE
.sp
\fB\-N, \-\-table\-columns\fP \fInames\fP
.RS 4
Specify column names with a comma\-separated list. The names are used for the table header
and for column addressing in option arguments. See also \fB\-\-table\-column\fP.
.RE
.sp
\fB\-l, \-\-table\-columns\-limit\fP \fInumber\fP
.RS 4
Specify the maximum number of input columns. The last column will contain all remaining line data if the limit is smaller than the number of columns in the input data.
.RE
.sp
\fB\-R, \-\-table\-right\fP \fIcolumns\fP
.RS 4
Right align text in the specified columns.
.RE
.sp
\fB\-T, \-\-table\-truncate\fP \fIcolumns\fP
.RS 4
Specify the columns where text can be truncated when necessary, otherwise very long table entries may be printed on multiple lines.
.RE
.sp
\fB\-E, \-\-table\-noextreme\fP \fIcolumns\fP
.RS 4
Specify the columns where longer\-than\-average content should be ignored when calculating the column width. The option influences width calculation and table formatting, but the printed text is not affected.
.sp
This option is active by default for the last visible column.
.RE
.sp
\fB\-e, \-\-table\-header\-repeat\fP
.RS 4
Print header line for each page.
.RE
.sp
\fB\-K, \-\-table\-header\-as\-columns\fP
.RS 4
Use the first input line as table header. This option is mutually exclusive with \fB\-\-table\-columns\fP and \fB\-\-table\-column\fP.
.RE
.sp
\fB\-W, \-\-table\-wrap\fP \fIcolumns\fP
.RS 4
Specify the columns where multi\-line cells can be used for long text. By default, text is wrapped according to column width. Use \fB\-\-wrap\-separator\fP to wrap at custom separator characters instead.
.RE
.sp
\fB\-\-wrap\-separator\fP \fIstring\fP
.RS 4
Use \fIstring\fP as a separator for wrapping text within columns that have wrapping enabled. The separator is replaced with newlines when the text is displayed. This option requires table mode and columns with wrapping enabled (see \fB\-\-table\-wrap\fP). For example, use \f(CR|\fP to allow wrapping at pipe characters within column data.
.RE
.sp
\fB\-H, \-\-table\-hide\fP \fIcolumns\fP
.RS 4
Don\(cqt print the specified columns. The special placeholder \*(Aq\fB\-\fP\*(Aq may be used to hide all unnamed columns (see \fB\-\-table\-columns\fP).
.RE
.sp
\fB\-O, \-\-table\-order\fP \fIcolumns\fP
.RS 4
Specify the output column order.
.RE
.sp
\fB\-n, \-\-table\-name\fP \fIname\fP
.RS 4
Specify the table name used for JSON output. The default is "table".
.RE
.sp
\fB\-m, \-\-table\-maxout\fP
.RS 4
Fill all available space on output.
.RE
.sp
\fB\-L, \-\-keep\-empty\-lines\fP
.RS 4
Preserve whitespace\-only lines in the input. The default is to ignore all empty lines. This option\(cqs original name was \fB\-\-table\-empty\-lines\fP, but has since been deprecated because it gives the false impression that the option only applies to table mode.
.RE
.sp
\fB\-r, \-\-tree\fP \fIcolumn\fP
.RS 4
Specify the column to use for a tree\-like output. Note that the circular dependencies and other anomalies in child and parent relation are silently ignored.
.RE
.sp
\fB\-i, \-\-tree\-id\fP \fIcolumn\fP
.RS 4
Specify the column that contains each line\(cqs unique child ID for a child\-parent relation.
.RE
.sp
\fB\-p, \-\-tree\-parent\fP \fIcolumn\fP
.RS 4
Specify the column that contains each line\(cqs parent ID for a child\-parent relation.
.RE
.sp
\fB\-x, \-\-fillrows\fP
.RS 4
Fill rows before filling columns.
.RE
.sp
\fB\-\-color\fP[\fB=\fP\fIwhen\fP]
.RS 4
Colorize the output. The optional argument \fIwhen\fP can be \fBauto\fP, \fBnever\fP or \fBalways\fP. If the \fIwhen\fP argument is omitted, it defaults to \fBauto\fP. The colors can be disabled; for the current built\-in default see the \fB\-\-help\fP output. See also the \fBCOLORS\fP section.
.RE
.sp
\fB\-h\fP, \fB\-\-help\fP
.RS 4
Display help text and exit.
.RE
.sp
\fB\-V\fP, \fB\-\-version\fP
.RS 4
Display version and exit.
.RE
.SH "COLORS"
.sp
The output colorization is implemented by \fBterminal\-colors.d\fP(5) functionality.
Implicit coloring can be disabled by an empty file
.RS 3
.ll -.6i
.sp
\fI/etc/terminal\-colors.d/column.disable\fP
.br
.RE
.ll
.sp
for the \fBcolumn\fP command or for all tools by
.RS 3
.ll -.6i
.sp
\fI/etc/terminal\-colors.d/disable\fP
.br
.RE
.ll
.sp
Since version 2.41, the $NO_COLOR environment variable is also supported to
disable output colorization unless explicitly enabled by a command\-line option.
.sp
The user\-specific \fI$XDG_CONFIG_HOME/terminal\-colors.d\fP
or \fI$HOME/.config/terminal\-colors.d\fP overrides the global setting.
.sp
Note that the output colorization may be enabled by default, and in this case
\fIterminal\-colors.d\fP directories do not have to exist yet.
.sp
The default color scheme name is "column," and it can be overridden by
.RS 3
.ll -.6i
.sp
\fB\-\-table\-colorscheme name\fP
.br
.RE
.ll
.sp
Then \fIname\fP[.disable|enable|scheme] file may be used in \fI/etc/terminal\-colors.d/\fP,
\fI$XDG_CONFIG_HOME/terminal\-colors.d\fP, or \fI$HOME/.config/terminal\-colors.d/\fP.
.sp
The logical color name (key) in the color scheme may be addressed by column properties
\fBcolorkey=\fP and \fBheadercolorkey=\fP. For example
.sp
.if n .RS 4
.nf
.fam C
echo \*(Aqimportant red\*(Aq           > ~/.config/terminal\-colors.d/cooltable.scheme
echo \*(Aqimportant\-header 37;41\*(Aq >> ~/.config/terminal\-colors.d/cooltable.scheme
echo \-e "a b c\(rsnaa bb cc\(rsnaaa bbb ccc" | column \-t \(rs
        \-\-table\-colorscheme=cooltable \(rs
        \-C name=AAA,colorkey=important,headercolorkey=important\-header \(rs
        \-C name=BBB,color=magenta,headercolor=cyan \(rs
        \-C name=CCC,color=green
.fam
.fi
.if n .RE
.sp
This will create a color scheme with the name "cooltable" and colorize the first
column header and data according to keys from the scheme. The other two columns
will be colorized by direct color names.
.SH "ENVIRONMENT"
.sp
\fBCOLUMNS\fP
.RS 4
is used to determine the size of the screen if no other information is available.
.RE
.sp
\fBLIBSMARTCOLS_DEBUG\fP=all
.RS 4
enables libsmartcols debug output.
.RE
.sp
\fBLIBSMARTCOLS_DEBUG_PADDING\fP=on
.RS 4
use visible padding characters.
.RE
.sp
\fBLIBSMARTCOLS_JSON\fP=compact|lines
.RS 4
Controls JSON output format when using \fB\-\-json\fP. Supported values are
\fBcompact\fP for JSON output with minimal whitespace, and \fBlines\fP for JSON Lines
format (one JSON object per line). If unset or set to any other value,
pretty\-printed JSON is used.
.RE
.SH "HISTORY"
.sp
The \fBcolumn\fP command appeared in 4.3BSD\-Reno.
.SH "BUGS"
.sp
Version 2.23 changed the \fB\-s\fP option to be non\-greedy, for example:
.sp
.if n .RS 4
.nf
.fam C
printf "a:b:c\(rsn1::3\(rsn" | column \-t \-s \*(Aq:\*(Aq
.fam
.fi
.if n .RE
.sp
Old output:
.sp
.if n .RS 4
.nf
.fam C
a  b  c
1  3
.fam
.fi
.if n .RE
.sp
New output (since util\-linux 2.23):
.sp
.if n .RS 4
.nf
.fam C
a  b  c
1     3
.fam
.fi
.if n .RE
.sp
Historical versions of this tool indicated that "rows are filled before columns" by default, and that the \fB\-x\fP option reverses this. This wording did not reflect the actual behavior, and it has since been corrected (see above). Other implementations of \fBcolumn\fP may continue to use the older documentation, but the behavior should be identical in any case.
.SH "EXAMPLES"
.sp
Print fstab with a header line and align numbers to the right:
.sp
.if n .RS 4
.nf
.fam C
sed \*(Aqs/#.*//\*(Aq /etc/fstab | column \-\-table \-\-table\-columns SOURCE,TARGET,TYPE,OPTIONS,FREQ,PASS \-\-table\-right FREQ,PASS
.fam
.fi
.if n .RE
.sp
Print fstab and hide unnamed columns:
.sp
.if n .RS 4
.nf
.fam C
sed \*(Aqs/#.*//\*(Aq /etc/fstab | column \-\-table \-\-table\-columns SOURCE,TARGET,TYPE \-\-table\-hide \-
.fam
.fi
.if n .RE
.sp
Print a tree:
.sp
.if n .RS 4
.nf
.fam C
echo \-e \*(Aq1 0 A\(rsn2 1 AA\(rsn3 1 AB\(rsn4 2 AAA\(rsn5 2 AAB\*(Aq | column \-\-tree\-id 1 \-\-tree\-parent 2 \-\-tree 3
1  0  A
2  1  |\-AA
4  2  | |\-AAA
5  2  | `\-AAB
3  1  `\-AB
.fam
.fi
.if n .RE
.sp
Print table with custom wrap separator:
.sp
.if n .RS 4
.nf
.fam C
echo \-e \*(AqName:Description\(rsnJohn:A|software|developer\(rsnJane:A|data|scientist\*(Aq | column \-\-table \-\-separator \*(Aq:\*(Aq \-\-table\-wrap 2 \-\-wrap\-separator \*(Aq|\*(Aq
Name  Description
John  A
      software
      developer
Jane  A
      data
      scientist
.fam
.fi
.if n .RE
.SH "SEE ALSO"
.sp
\fBcolrm\fP(1),
\fBls\fP(1),
\fBpaste\fP(1),
\fBsort\fP(1)
.SH "REPORTING BUGS"
.sp
For bug reports, use the \c
.URL "https://github.com/util\-linux/util\-linux/issues" "issue tracker" "."
.SH "AVAILABILITY"
.sp
The \fBcolumn\fP command is part of the util\-linux package which can be downloaded from \c
.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."