xref: /original-bsd/usr.bin/cut/cut.1 (revision de3f5c4e)
1.\" Copyright (c) 1989, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"     @(#)cut.1	5.4 (Berkeley) 05/06/91
7.\"
8.Dd
9.Dt CUT 1
10.Os
11.Sh NAME
12.Nm cut
13.Nd select portions of each line of a file
14.Sh SYNOPSIS
15.Nm cut
16.Fl c Ar list
17.Ar
18.Nm cut
19.Fl f Ar list
20.Op Fl d Ar string
21.Op Fl s
22.Ar
23.Sh DESCRIPTION
24The
25.Nm cut
26utility selects portions of each line (as specified by
27.Ar list  )
28from each
29.Ar file
30(or the standard input by default), and writes them to the
31standard output.
32The items specified by
33.Ar list
34can be in terms of column position or in terms of fields delimited
35by a special character. Column numbering starts from 1.
36.Pp
37.Ar List
38is a comma or whitespace separated set of increasing numbers and/or
39number ranges.
40Number ranges consist of a number, a dash
41.Pq Li \- ,
42and a second number
43and select the fields or columns from the first number to the second,
44inclusive.
45Numbers or number ranges may be preceded by a dash, which selects all
46fields or columns from 1 to the first number.
47Numbers or number ranges may be followed by a dash, which selects all
48fields or columns from the last number to the end of the line.
49Numbers and number ranges may be repeated, overlapping, and in any order.
50It is not an error to select fields or columns not present in the
51input line.
52.Pp
53The options are as follows:
54.Bl -tag -width Fl
55.It Fl c Ar list
56The
57.Ar list
58specifies character positions.
59.It Fl d Ar string
60Use
61.Ar char
62as the field delimiter character instead of the tab character.
63.It Fl f Ar list
64The
65.Ar list
66specifies fields, delimited in the input by a single tab character.
67Output fields are separated by a single tab character.
68.It Fl s
69Suppresses lines with no field delimiter characters.
70Unless specified, lines with no delimiters are passed through unmodified.
71.El
72.Pp
73.Nm Cut
74exits 0 on success, 1 if an error occurred.
75.Sh SEE ALSO
76.Xr paste 1
77.Sh STANDARDS
78The
79.Nm cut
80utility is expected to conform to
81.St -p1003.2 .
82