]> git.ipfire.org Git - thirdparty/util-linux.git/blob - text-utils/column.1.adoc
Merge branch 'lsfd--close-all' of https://github.com/masatake/util-linux
[thirdparty/util-linux.git] / text-utils / column.1.adoc
1 //po4a: entry man manual
2 ////
3 Copyright (c) 1989, 1990, 1993
4 The Regents of the University of California. All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 3. All advertising materials mentioning features or use of this software
15 must display the following acknowledgement:
16 This product includes software developed by the University of
17 California, Berkeley and its contributors.
18 4. Neither the name of the University nor the names of its contributors
19 may be used to endorse or promote products derived from this software
20 without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 SUCH DAMAGE.
33
34 @(#)column.1 8.1 (Berkeley) 6/6/93
35 ////
36 = column(1)
37 :doctype: manpage
38 :man manual: User Commands
39 :man source: util-linux {release-version}
40 :page-layout: base
41 :command: column
42
43 == NAME
44
45 column - columnate lists
46
47 == SYNOPSIS
48
49 *column* [options] [_file_ ...]
50
51 == DESCRIPTION
52
53 The *column* utility formats its input into multiple columns. The util support three modes:
54
55 *columns are filled before rows*::
56 This is the default mode (required by backward compatibility).
57
58 *rows are filled before columns*::
59 This mode is enabled by option *-x, --fillrows*
60
61 *table*::
62 Determine the number of columns the input contains and create a table. This mode is enabled by option *-t, --table* and columns formatting is possible to modify by *--table-** options. Use this mode if not sure. The output is aligned to the terminal width in interactive mode and the 80 columns in non-interactive mode (see *--output-width* for more details).
63
64 Input is taken from _file_, or otherwise from standard input. Empty lines are ignored and all invalid multibyte sequences are encoded by x<hex> convention.
65
66 == OPTIONS
67
68 The argument _columns_ for *--table-** options is a comma separated list of the
69 column names as defined by *--table-columns*, or names defined by
70 *--table-column* or it's column number in order as specified by input. It's
71 possible to mix names and numbers. The special placeholder '0' (e.g. -R0) may
72 be used to specify all columns and '-1' (e.g. -R -1) to specify the last visible column.
73 It's possible to use ranges like '1-5' when addressing columns by numbers.
74
75 *-J, --json*::
76 Use JSON output format to print the table, the option *--table-columns* is required and the option *--table-name* is recommended.
77
78 *-c, --output-width* _width_::
79 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 _width_ is not truncated by default. The default is a terminal width and the 80 columns in non-interactive mode. The column headers are never truncated.
80 +
81 The placeholder "unlimited" (or 0) is possible to use to not restrict output width. This is recommended for example when output to the files rather than on terminal.
82
83 *-d, --table-noheadings*::
84 Do not print header. This option allows the use of logical column names on the command line, but keeps the header hidden when printing the table.
85
86 *-o, --output-separator* _string_::
87 Specify the columns delimiter for table output (default is two spaces).
88
89 *-s, --separator* _separators_::
90 Specify the possible input item delimiters (default is whitespace).
91
92 *-t, --table*::
93 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 *--output-separator* option. Table output is useful for pretty-printing.
94
95 *-C, --table-column* _properties_::
96 Define one column by comma separated list of column attributes.
97 This option can be used more than once, every use defines just one column.
98 The properties replace some of *--table-* options. For example *--table-column
99 name=FOO,right* define one column where text is aligned to right. The option is
100 mutually exclusive to *--table-columns*.
101 +
102 The currently supported attributes are:
103 +
104 *name=string*;;
105 Specifies column name.
106 *trunc*;;
107 The column text can be truncated when necessary. The same as *--table-truncate*.
108 *right*;;
109 Right align text in the specified columns. The same as *--table-right*.
110 *width=number*;;
111 Specifies column width. The width is used as a hint only. The width is strictly followed
112 only when *strictwidth* attribute is used too.
113 *strictwidth*;;
114 Strictly follow column *width=* setting.
115 *noextreme*;;
116 Specify columns where is possible to ignore unusually long cells. See *--table-noextreme* for more details.
117 *wrap*;;
118 Specify columns where is possible to use multi-line cell for long text when necessary. See *--table-wrap*.
119 *hide*;;
120 Don't print specified columns. See *--table-hide*.
121 *json=type*;;
122 Define column type for JSON output, Supported are string, number and boolean.
123
124 *-N, --table-columns* _names_::
125 Specify the columns names by comma separated list of names. The names are used
126 for the table header or to address column in option argument. See also *--table-column*.
127
128 *-l, --table-columns-limit* _number_::
129 Specify maximal number of the input columns. The last column will contain all remaining line data if the limit is smaller than the number of the columns in the input data.
130
131 *-R, --table-right* _columns_::
132 Right align text in the specified columns.
133
134 *-T, --table-truncate* _columns_::
135 Specify columns where text can be truncated when necessary, otherwise very long table entries may be printed on multiple lines.
136
137 *-E, --table-noextreme* _columns_::
138 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.
139 +
140 The option is used for the last visible column by default.
141
142 *-e, --table-header-repeat*::
143 Print header line for each page.
144
145 *-W, --table-wrap* _columns_::
146 Specify columns where is possible to use multi-line cell for long text when necessary.
147
148 *-H, --table-hide* _columns_::
149 Don't print specified columns. The special placeholder '-' may be used to hide all unnamed columns (see *--table-columns*).
150
151 *-O, --table-order* _columns_::
152 Specify columns order on output.
153
154 *-n, --table-name* _name_::
155 Specify the table name used for JSON output. The default is "table".
156
157 *-m, --table-maxout*::
158 Fill all available space on output.
159
160 *-L, --keep-empty-lines*::
161 Preserve whitespace-only lines in the input. The default is ignore empty lines at all. This option's original name was *--table-empty-lines* but is now deprecated because it gives the false impression that the option only applies to table mode.
162
163 *-r, --tree* _column_::
164 Specify column to use tree-like output. Note that the circular dependencies and other anomalies in child and parent relation are silently ignored.
165
166 *-i, --tree-id* _column_::
167 Specify column with line ID to create child-parent relation.
168
169 *-p, --tree-parent* _column_::
170 Specify column with parent ID to create child-parent relation.
171
172 *-x, --fillrows*::
173 Fill rows before filling columns.
174
175 include::man-common/help-version.adoc[]
176
177 == ENVIRONMENT
178
179 The environment variable *COLUMNS* is used to determine the size of the screen if no other information is available.
180
181 == HISTORY
182
183 The *column* command appeared in 4.3BSD-Reno.
184
185 == BUGS
186
187 Version 2.23 changed the *-s* option to be non-greedy, for example:
188
189 ....
190 printf "a:b:c\n1::3\n" | column -t -s ':'
191 ....
192
193 Old output:
194
195 ....
196 a b c
197 1 3
198 ....
199
200 New output (since util-linux 2.23):
201
202 ....
203 a b c
204 1 3
205 ....
206
207 Historical versions of this tool indicated that "rows are filled before columns" by default, and that the *-x* option reverses this. This wording did not reflect the actual behavior, and it has since been corrected (see above). Other implementations of *column* may continue to use the older documentation, but the behavior should be identical in any case.
208
209 == EXAMPLES
210
211 Print fstab with header line and align number to the right:
212
213 ....
214 sed 's/#.*//' /etc/fstab | column --table --table-columns SOURCE,TARGET,TYPE,OPTIONS,PASS,FREQ --table-right PASS,FREQ
215 ....
216
217 Print fstab and hide unnamed columns:
218
219 ....
220 sed 's/#.*//' /etc/fstab | column --table --table-columns SOURCE,TARGET,TYPE --table-hide -
221 ....
222
223 Print a tree:
224
225 ....
226 echo -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
227 1 0 A
228 2 1 |-AA
229 4 2 | |-AAA
230 5 2 | `-AAB
231 3 1 `-AB
232 ....
233
234 == SEE ALSO
235
236 *colrm*(1),
237 *ls*(1),
238 *paste*(1),
239 *sort*(1)
240
241 include::man-common/bugreports.adoc[]
242
243 include::man-common/footer.adoc[]
244
245 ifdef::translation[]
246 include::man-common/translation.adoc[]
247 endif::[]