xref: /freebsd/usr.bin/col/col.1 (revision edf8578117e8844e02c0121147f45e4609b30680)
1.\" Copyright (c) 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Michael Rendell.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)col.1	8.1 (Berkeley) 6/29/93
32.\"
33.Dd October 21, 2020
34.Dt COL 1
35.Os
36.Sh NAME
37.Nm col
38.Nd filter reverse line feeds from input
39.Sh SYNOPSIS
40.Nm
41.Op Fl bfhpx
42.Op Fl l Ar num
43.Sh DESCRIPTION
44The
45.Nm
46utility filters out reverse (and half reverse) line feeds so that the output is
47in the correct order with only forward and half forward line
48feeds, and replaces white-space characters with tabs where possible.
49.Pp
50The
51.Nm
52utility reads from the standard input and writes to the standard output.
53.Pp
54The options are as follows:
55.Bl -tag -width indent
56.It Fl b
57Do not output any backspaces, printing only the last character
58written to each column position.
59.It Fl f
60Forward half line feeds are permitted (``fine'' mode).
61Normally characters printed on a half line boundary are printed
62on the following line.
63.It Fl h
64Do not output multiple spaces instead of tabs (default).
65.It Fl l Ar num
66Buffer at least
67.Ar num
68lines in memory.
69By default, 128 lines are buffered.
70.It Fl p
71Force unknown control sequences to be passed through unchanged.
72Normally,
73.Nm
74will filter out any control sequences from the input other than those
75recognized and interpreted by itself, which are listed below.
76.It Fl x
77Output multiple spaces instead of tabs.
78.El
79.Pp
80In the input stream,
81.Nm
82understands both the escape sequences of the form escape-digit
83mandated by
84.St -susv2
85and the traditional
86.Bx
87format escape-control-character.
88The control sequences for carriage motion and their ASCII values
89are as follows:
90.Pp
91.Bl -tag -width "carriage return" -compact
92.It ESC\-BELL
93reverse line feed (escape then bell).
94.It ESC\-7
95reverse line feed (escape then 7).
96.It ESC\-BACKSPACE
97half reverse line feed (escape then backspace).
98.It ESC\-8
99half reverse line feed (escape then 8).
100.It ESC\-TAB
101half forward line feed (escape than tab).
102.It ESC\-9
103half forward line feed (escape then 9).
104In
105.Fl f
106mode, this sequence may also occur in the output stream.
107.It backspace
108moves back one column (8); ignored in the first column
109.It carriage return
110(13)
111.It newline
112forward line feed (10); also does carriage return
113.It shift in
114shift to normal character set (15)
115.It shift out
116shift to alternate character set (14)
117.It space
118moves forward one column (32)
119.It tab
120moves forward to next tab stop (9)
121.It vertical tab
122reverse line feed (11)
123.El
124.Pp
125All unrecognized control characters and escape sequences are
126discarded.
127.Pp
128The
129.Nm
130utility keeps track of the character set as characters are read and makes
131sure the character set is correct when they are output.
132.Pp
133If the input attempts to back up to the last flushed line,
134.Nm
135will display a warning message.
136.Sh ENVIRONMENT
137The
138.Ev LANG , LC_ALL
139and
140.Ev LC_CTYPE
141environment variables affect the execution of
142.Nm
143as described in
144.Xr environ 7 .
145.Sh EXIT STATUS
146.Ex -std
147.Sh EXAMPLES
148We can use
149.Nm
150to filter the output of
151.Xr man 1
152and remove the backspace characters (
153.Em ^H
154) before searching for some text:
155.Bd -literal -offset indent
156man ls | col -b | grep HISTORY
157.Ed
158.Sh SEE ALSO
159.Xr expand 1
160.Sh STANDARDS
161The
162.Nm
163utility conforms to
164.St -susv2 .
165.Sh HISTORY
166A
167.Nm
168command
169appeared in
170.At v6 .
171