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