xref: /freebsd/usr.bin/col/col.1 (revision 43a5ec4eb41567cc92586503212743d89686d78f)
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.\" $FreeBSD$
33.\"
34.Dd October 21, 2020
35.Dt COL 1
36.Os
37.Sh NAME
38.Nm col
39.Nd filter reverse line feeds from input
40.Sh SYNOPSIS
41.Nm
42.Op Fl bfhpx
43.Op Fl l Ar num
44.Sh DESCRIPTION
45The
46.Nm
47utility filters out reverse (and half reverse) line feeds so that the output is
48in the correct order with only forward and half forward line
49feeds, and replaces white-space characters with tabs where possible.
50.Pp
51The
52.Nm
53utility reads from the standard input and writes to the standard output.
54.Pp
55The options are as follows:
56.Bl -tag -width indent
57.It Fl b
58Do not output any backspaces, printing only the last character
59written to each column position.
60.It Fl f
61Forward half line feeds are permitted (``fine'' mode).
62Normally characters printed on a half line boundary are printed
63on the following line.
64.It Fl h
65Do not output multiple spaces instead of tabs (default).
66.It Fl l Ar num
67Buffer at least
68.Ar num
69lines in memory.
70By default, 128 lines are buffered.
71.It Fl p
72Force unknown control sequences to be passed through unchanged.
73Normally,
74.Nm
75will filter out any control sequences from the input other than those
76recognized and interpreted by itself, which are listed below.
77.It Fl x
78Output multiple spaces instead of tabs.
79.El
80.Pp
81In the input stream,
82.Nm
83understands both the escape sequences of the form escape-digit
84mandated by
85.St -susv2
86and the traditional
87.Bx
88format escape-control-character.
89The control sequences for carriage motion and their ASCII values
90are as follows:
91.Pp
92.Bl -tag -width "carriage return" -compact
93.It ESC\-BELL
94reverse line feed (escape then bell).
95.It ESC\-7
96reverse line feed (escape then 7).
97.It ESC\-BACKSPACE
98half reverse line feed (escape then backspace).
99.It ESC\-8
100half reverse line feed (escape then 8).
101.It ESC\-TAB
102half forward line feed (escape than tab).
103.It ESC\-9
104half forward line feed (escape then 9).
105In
106.Fl f
107mode, this sequence may also occur in the output stream.
108.It backspace
109moves back one column (8); ignored in the first column
110.It carriage return
111(13)
112.It newline
113forward line feed (10); also does carriage return
114.It shift in
115shift to normal character set (15)
116.It shift out
117shift to alternate character set (14)
118.It space
119moves forward one column (32)
120.It tab
121moves forward to next tab stop (9)
122.It vertical tab
123reverse line feed (11)
124.El
125.Pp
126All unrecognized control characters and escape sequences are
127discarded.
128.Pp
129The
130.Nm
131utility keeps track of the character set as characters are read and makes
132sure the character set is correct when they are output.
133.Pp
134If the input attempts to back up to the last flushed line,
135.Nm
136will display a warning message.
137.Sh ENVIRONMENT
138The
139.Ev LANG , LC_ALL
140and
141.Ev LC_CTYPE
142environment variables affect the execution of
143.Nm
144as described in
145.Xr environ 7 .
146.Sh EXIT STATUS
147.Ex -std
148.Sh EXAMPLES
149We can use
150.Nm
151to filter the output of
152.Xr man 1
153and remove the backspace characters (
154.Em ^H
155) before searching for some text:
156.Bd -literal -offset indent
157man ls | col -b | grep HISTORY
158.Ed
159.Sh SEE ALSO
160.Xr expand 1
161.Sh STANDARDS
162The
163.Nm
164utility conforms to
165.St -susv2 .
166.Sh HISTORY
167A
168.Nm
169command
170appeared in
171.At v6 .
172