summaryrefslogtreecommitdiffstats
path: root/text-utils/column.1
blob: 9ce5879e506296d70b2daa1ee6d992f8e9dfc833 (plain)
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
.\" Copyright (c) 1989, 1990, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"     @(#)column.1	8.1 (Berkeley) 6/6/93
.\"
.TH COLUMN 1 "January 2017" "util-linux" "User Commands"
.SH NAME
column \- columnate lists
.SH SYNOPSIS
.BR column " [options]"
.RI [ file ...]
.SH DESCRIPTION
The
.B column
utility formats its input into multiple columns.  The util support three modes:
.TP
.B columns are filled before rows
This is the default mode (required by backward compatibility).
.TP
.B rows are filled before columns
This mode is enabled by option \fB-x, \-\-fillrows\fP
.TP
.B table
Determine the number of columns the input contains and create a table.  This
mode is enabled by option \fB-t, \-\-table\fP and columns formatting is
possible to modify by \fB\-\-table-*\fP options.  Use this mode if not sure.
.PP
Input is taken from \fIfile\fR, or otherwise from standard input.  Empty lines
are ignored and all invalid multibyte sequences are encoded by \\x<hex> convention.
.PP
.SH OPTIONS
The argument \fIcolumns\fP for \fB\-\-table-*\fP options is comma separated
list of the column names as defined by \fB\-\-table-columns\fP or it's column
number in order as specified by input. It's possible to mix names and numbers.
.PP
.IP "\fB\-J, \-\-json\fP"
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.
.IP "\fB\-c, \-\-output\-width\fP \fIwidth\fP"
Output is formatted to a width specified as number of characters. The original
name of this option is --columns; this name is deprecated since v2.30. Note that input
longer than \fIwidth\fP is not truncated by default.
.IP "\fB\-d, \-\-table\-noheadings\fP"
Do not print header. This option allows to use logical column names on command line, but keep the header hidden when print the table.
.IP "\fB\-o, \-\-output\-separator\fP \fIstring\fP"
Specify the columns delimiter for table output (default is two spaces).
.IP "\fB\-s, \-\-separator\fP \fIseparators\fP"
Specify the possible input item delimiters (default is whitespace).
.IP "\fB\-t, \-\-table\fP"
Determine the number of columns the input contains and create a table.
Columns are delimited with whitespace, by default, or with the characters
supplied using the \fB\-\-output\-separator\fP option.
Table output is useful for pretty-printing.
.IP "\fB\-N, \-\-table-columns\fP \fInames\fP"
Specify the columns names by comma separated list of names. The names are used
for the table header or to address column in option arguments.
.IP "\fB\-R, \-\-table-right\fP \fIcolumns\fP"
Right align text in the specified columns.
.IP "\fB\-T, \-\-table-truncate\fP \fIcolumns\fP"
Specify columns where is allowed to truncate text when necessary, otherwise
very long table entries may be printed on multiple lines.
.IP "\fB\-E, \-\-table-noextreme\fP \fIcolumns\fP"
Specify columns where is possible to ignore unusually long (longer than
average) cells when calculate column width.  The option has impact to the width
calculation and table formatting, but the printed text is not affected.

The option is used for the last visible column by default.

.IP "\fB\-e, \-\-table\-header\-repeat\fP"
Print header line for each page.
.IP "\fB\-W, \-\-table-wrap\fP \fIcolumns\fP"
Specify columns where is possible to use multi-line cell for long text when
necessary.
.IP "\fB\-H, \-\-table-hide\fP \fIcolumns\fP"
Don't print specified columns. The special placeholder '-' maybe be used to
hide all unnamed columns (see --table-columns).
.IP "\fB\-O, \-\-table-order\fP \fIcolumns\fP"
Specify columns order on output.
.IP "\fB\-n, \-\-table-name\fP \fIname\fP"
Specify the table name used for JSON output. The default is "table".
.IP "\fB\-L, \-\-table\-empty\-lines\fP"
Insert empty line to the table for each empty line on input. The default
is ignore empty lines at all.
.IP "\fB\-r, \-\-tree\fP \fIcolumn\fP"
Specify column to use tree-like output. Note that the circular dependencies and
another anomalies in child and parent relation are silently ignored.
.IP "\fB\-i, \-\-tree\-id\fP \fIcolumn\fP"
Specify column with line ID to create child-parent relation.
.IP "\fB\-p, \-\-tree\-parent\fP \fIcolumn\fP"
Specify column with parent ID to create child-parent relation.
.PP
.IP "\fB\-x, \-\-fillrows\fP"
Fill rows before filling columns.
.IP "\fB\-V\fR, \fB\-\-version\fR"
Display version information and exit.
.IP "\fB\-h, \-\-help\fP"
Display help text and exit.
.SH ENVIRONMENT
The environment variable \fBCOLUMNS\fR is used to determine the size of
the screen if no other information is available.
.SH EXAMPLES
Print fstab with header line and align number to the right:
.EX
\fBsed 's/#.*//' /etc/fstab | column --table --table-columns SOURCE,TARGET,TYPE,OPTIONS,PASS,FREQ --table-right PASS,FREQ\fR
.EE
.PP
Print fstab and hide unnamed columns:
.EX
\fBsed 's/#.*//' /etc/fstab | column --table --table-columns SOURCE,TARGET,TYPE --table-hide -\fR
.EE
.PP

.PP
Print a tree:
.EX
\fBecho -e '1 0 A\\n2 1 AA\\n3 1 AB\\n4 2 AAA\\n5 2 AAB' | column --tree-id 1 --tree-parent 2 --tree 3\fR
1  0  A
2  1  |-AA
4  2  | |-AAA
5  2  | `-AAB
3  1  `-AB
.EE
.SH BUGS
Version 2.23 changed the
.B \-s
option to be non-greedy, for example:
.PP
.EX
\fBprintf "a:b:c\\n1::3\\n" | column  -t -s ':'\fR
.EE
.PP
Old output:
.EX
a  b  c
1  3
.EE
.PP
New output (since util-linux 2.23):
.EX
a  b  c
1     3
.EE
.SH "SEE ALSO"
.BR colrm (1),
.BR ls (1),
.BR paste (1),
.BR sort (1)
.SH HISTORY
The column command appeared in 4.3BSD-Reno.
.SH AVAILABILITY
The column command is part of the util-linux package and is available from
https://www.kernel.org/pub/linux/utils/util-linux/.