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