BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / cut / cut.1
CommitLineData
b5dc1377 1.\" Copyright (c) 1989, 1990 The Regents of the University of California.
12cf7852
KB
2.\" All rights reserved.
3.\"
1c15e888
C
4.\" Redistribution and use in source and binary forms are permitted provided
5.\" that: (1) source distributions retain this entire copyright notice and
6.\" comment, and (2) distributions including binaries display the following
7.\" acknowledgement: ``This product includes software developed by the
8.\" University of California, Berkeley and its contributors'' in the
9.\" documentation or other materials provided with the distribution and in
10.\" all advertising materials mentioning features or use of this software.
11.\" Neither the name of the University nor the names of its contributors may
12.\" be used to endorse or promote products derived from this software without
13.\" specific prior written permission.
14.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
15.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12cf7852 17.\"
1c15e888 18.\" @(#)cut.1 5.3 (Berkeley) 7/24/90
12cf7852 19.\"
1c15e888 20.Dd July 24, 1990
b5dc1377
CL
21.Dt CUT 1
22.Os BSD 4.4
23.Sh NAME
24.Nm cut
25.Nd select portions of each line of a file
26.Sh SYNOPSIS
27.Nm cut
28.Ar list
29.Ar
30.br
31.Nm cut
32.Ar list
33.Op Fl s
34.Op Fl d Ar string
35.Ar
36.Sh DESCRIPTION
12cf7852 37The
b5dc1377 38.Nm cut
12cf7852 39utility selects portions of each line (as specified by
b5dc1377 40.Ar list )
12cf7852 41from each
b5dc1377 42.Ar file
12cf7852
KB
43(or the standard input by default), and writes them to the
44standard output.
45The items specified by
b5dc1377 46.Ar list
12cf7852 47can be in terms of column position or in terms of fields delimited
5325ced3 48by a special character. Column numbering starts from 1.
b5dc1377
CL
49.Pp
50.Ar List
5325ced3 51is a comma or whitespace separated set of increasing numbers and/or
12cf7852 52number ranges.
b5dc1377
CL
53Number ranges consist of a number, a dash
54.Li (``\-'') ,
55and a second number
12cf7852
KB
56and select the fields or columns from the first number to the second,
57inclusive.
58Numbers or number ranges may be preceded by a dash, which selects all
59fields or columns from 1 to the first number.
60Numbers or number ranges may be followed by a dash, which selects all
61fields or columns from the last number to the end of the line.
62Numbers and number ranges may be repeated, overlapping, and in any order.
63It is not an error to select fields or columns not present in the
64input line.
b5dc1377 65.Pp
12cf7852 66The options are as follows:
b5dc1377
CL
67.Tw Fl
68.Tp Cx Fl c
69.Cx \&\ \&
70.Ar list
71.Cx
12cf7852 72The
b5dc1377 73.Ar list
12cf7852 74specifies character positions.
b5dc1377
CL
75.Tp Cx Fl f
76.Cx \&\ \&
77.Ar list
78.Cx
12cf7852 79The
b5dc1377 80.Ar list
12cf7852
KB
81specifies fields, delimited in the input by a single tab character.
82Output fields are separated by a single tab character.
b5dc1377
CL
83.Tp Cx Fl d
84.Cx \&\ \&
85.Ar char
86.Cx
12cf7852 87Use
b5dc1377 88.Ar char
12cf7852 89as the field delimiter character instead of the tab character.
b5dc1377 90.Tp Fl s
12cf7852
KB
91Suppresses lines with no field delimiter characters.
92Unless specified, lines with no delimiters are passed through unmodified.
b5dc1377
CL
93.Tp
94.Pp
95.Nm Cut
5325ced3 96exits 0 on success, 1 if an error occurred.
b5dc1377
CL
97.Sh SEE ALSO
98.Xr paste 1
99.Sh STANDARDS
12cf7852 100The
b5dc1377 101.Nm cut
12cf7852 102function is expected to be POSIX 1003.2 compatible.