xref: /openbsd/usr.bin/col/col.1 (revision f6aab3d8)
1.\"	$OpenBSD: col.1,v 1.15 2020/02/08 01:09:57 jsg Exp $
2.\"	$NetBSD: col.1,v 1.4 1995/03/26 05:25:52 glass Exp $
3.\"
4.\" Copyright (c) 1990, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" This code is derived from software contributed to Berkeley by
8.\" Michael Rendell.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\" 3. 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.\"     @(#)col.1	8.1 (Berkeley) 6/29/93
35.\"
36.Dd $Mdocdate: February 8 2020 $
37.Dt COL 1
38.Os
39.Sh NAME
40.Nm col
41.Nd filter reverse line feeds and backspaces from input
42.Sh SYNOPSIS
43.Nm col
44.Op Fl bfhx
45.Op Fl l Ar num
46.Sh DESCRIPTION
47.Nm
48filters out reverse (and half-reverse) line feeds so that the output is
49in the correct order with only forward and half-forward line
50feeds, and replaces whitespace characters with tabs where possible.
51.Pp
52.Nm
53reads from the standard input and writes to the standard output.
54.Pp
55The options are as follows:
56.Bl -tag -width Ds
57.It Fl b
58Do not output any backspaces, printing only the last character
59written to each column position.
60This can be useful in processing the output of
61.Xr mandoc 1 .
62.It Fl f
63Forward half-line feeds are permitted
64.Pf ( Dq fine
65mode).
66Normally characters printed on a half-line boundary are printed
67on the following line.
68.It Fl h
69Compress spaces into tabs.
70This is the default behavior.
71.It Fl l Ar num
72Buffer at least
73.Ar num
74lines in memory.
75By default, 128 lines are buffered.
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 "escape-backspace" -compact
92.It escape\-bell
93Reverse line feed (27 then 7).
94.It escape\-digit\-7
95Reverse line feed (27 then 55).
96.It escape\-backspace
97Half reverse line feed (27 then 8).
98.It escape\-digit\-8
99Half reverse line feed (27 then 56).
100.It escape\-tab
101Half forward line feed (27 then 9).
102.It escape\-digit\-9
103Half forward line feed (27 then 57).
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
128.Nm
129keeps track of the character set as characters are read and makes
130sure the character set is correct when they are output.
131.Pp
132If the input attempts to back up to the last flushed line,
133.Nm
134will display a warning message.
135.Sh SEE ALSO
136.Xr expand 1
137.Sh HISTORY
138A
139.Nm
140command appeared in
141.At v5 .
142