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