49 |
7u83 |
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 |
.\" Redistribution and use in source and binary forms, with or without
|
|
|
8 |
.\" modification, are permitted provided that the following conditions
|
|
|
9 |
.\" are met:
|
|
|
10 |
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
11 |
.\" notice, this list of conditions and the following disclaimer.
|
|
|
12 |
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
13 |
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
14 |
.\" documentation and/or other materials provided with the distribution.
|
|
|
15 |
.\" 3. Neither the name of the University nor the names of its contributors
|
|
|
16 |
.\" may be used to endorse or promote products derived from this software
|
|
|
17 |
.\" without specific prior written permission.
|
|
|
18 |
.\"
|
|
|
19 |
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
20 |
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
21 |
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
22 |
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
23 |
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
24 |
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
25 |
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
26 |
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
27 |
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
28 |
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
29 |
.\" SUCH DAMAGE.
|
|
|
30 |
.\"
|
|
|
31 |
.\" @(#)cut.1 8.1 (Berkeley) 6/6/93
|
|
|
32 |
.\" $FreeBSD: releng/12.0/usr.bin/cut/cut.1 322013 2017-08-03 14:35:02Z sevan $
|
|
|
33 |
.\"
|
|
|
34 |
.Dd August 3, 2017
|
|
|
35 |
.Dt CUT 1
|
|
|
36 |
.Os
|
|
|
37 |
.Sh NAME
|
|
|
38 |
.Nm cut
|
|
|
39 |
.Nd cut out selected portions of each line of a file
|
|
|
40 |
.Sh SYNOPSIS
|
|
|
41 |
.Nm
|
|
|
42 |
.Fl b Ar list
|
|
|
43 |
.Op Fl n
|
|
|
44 |
.Op Ar
|
|
|
45 |
.Nm
|
|
|
46 |
.Fl c Ar list
|
|
|
47 |
.Op Ar
|
|
|
48 |
.Nm
|
|
|
49 |
.Fl f Ar list
|
|
|
50 |
.Op Fl w | Fl d Ar delim
|
|
|
51 |
.Op Fl s
|
|
|
52 |
.Op Ar
|
|
|
53 |
.Sh DESCRIPTION
|
|
|
54 |
The
|
|
|
55 |
.Nm
|
|
|
56 |
utility cuts out selected portions of each line (as specified by
|
|
|
57 |
.Ar list )
|
|
|
58 |
from each
|
|
|
59 |
.Ar file
|
|
|
60 |
and writes them to the standard output.
|
|
|
61 |
If no
|
|
|
62 |
.Ar file
|
|
|
63 |
arguments are specified, or a file argument is a single dash
|
|
|
64 |
.Pq Sq Fl ,
|
|
|
65 |
.Nm
|
|
|
66 |
reads from the standard input.
|
|
|
67 |
The items specified by
|
|
|
68 |
.Ar list
|
|
|
69 |
can be in terms of column position or in terms of fields delimited
|
|
|
70 |
by a special character.
|
|
|
71 |
Column and field numbering start from 1.
|
|
|
72 |
.Pp
|
|
|
73 |
The
|
|
|
74 |
.Ar list
|
|
|
75 |
option argument
|
|
|
76 |
is a comma or whitespace separated set of increasing numbers and/or
|
|
|
77 |
number ranges.
|
|
|
78 |
Number ranges consist of a number, a dash
|
|
|
79 |
.Pq Sq \- ,
|
|
|
80 |
and a second number
|
|
|
81 |
and select the columns or fields from the first number to the second,
|
|
|
82 |
inclusive.
|
|
|
83 |
Numbers or number ranges may be preceded by a dash, which selects all
|
|
|
84 |
columns or fields from 1 to the last number.
|
|
|
85 |
Numbers or number ranges may be followed by a dash, which selects all
|
|
|
86 |
columns or fields from the last number to the end of the line.
|
|
|
87 |
Numbers and number ranges may be repeated, overlapping, and in any order.
|
|
|
88 |
It is not an error to select columns or fields not present in the
|
|
|
89 |
input line.
|
|
|
90 |
.Pp
|
|
|
91 |
The options are as follows:
|
|
|
92 |
.Bl -tag -width indent
|
|
|
93 |
.It Fl b Ar list
|
|
|
94 |
The
|
|
|
95 |
.Ar list
|
|
|
96 |
specifies byte positions.
|
|
|
97 |
.It Fl c Ar list
|
|
|
98 |
The
|
|
|
99 |
.Ar list
|
|
|
100 |
specifies character positions.
|
|
|
101 |
.It Fl d Ar delim
|
|
|
102 |
Use
|
|
|
103 |
.Ar delim
|
|
|
104 |
as the field delimiter character instead of the tab character.
|
|
|
105 |
.It Fl f Ar list
|
|
|
106 |
The
|
|
|
107 |
.Ar list
|
|
|
108 |
specifies fields, separated in the input by the field delimiter character
|
|
|
109 |
(see the
|
|
|
110 |
.Fl d
|
|
|
111 |
option).
|
|
|
112 |
Output fields are separated by a single occurrence of the field delimiter
|
|
|
113 |
character.
|
|
|
114 |
.It Fl n
|
|
|
115 |
Do not split multi-byte characters.
|
|
|
116 |
Characters will only be output if at least one byte is selected, and,
|
|
|
117 |
after a prefix of zero or more unselected bytes, the rest of the bytes
|
|
|
118 |
that form the character are selected.
|
|
|
119 |
.It Fl s
|
|
|
120 |
Suppress lines with no field delimiter characters.
|
|
|
121 |
Unless specified, lines with no delimiters are passed through unmodified.
|
|
|
122 |
.It Fl w
|
|
|
123 |
Use whitespace (spaces and tabs) as the delimiter.
|
|
|
124 |
Consecutive spaces and tabs count as one single field separator.
|
|
|
125 |
.El
|
|
|
126 |
.Sh ENVIRONMENT
|
|
|
127 |
The
|
|
|
128 |
.Ev LANG , LC_ALL
|
|
|
129 |
and
|
|
|
130 |
.Ev LC_CTYPE
|
|
|
131 |
environment variables affect the execution of
|
|
|
132 |
.Nm
|
|
|
133 |
as described in
|
|
|
134 |
.Xr environ 7 .
|
|
|
135 |
.Sh EXIT STATUS
|
|
|
136 |
.Ex -std
|
|
|
137 |
.Sh EXAMPLES
|
|
|
138 |
Extract users' login names and shells from the system
|
|
|
139 |
.Xr passwd 5
|
|
|
140 |
file as
|
|
|
141 |
.Dq name:shell
|
|
|
142 |
pairs:
|
|
|
143 |
.Pp
|
|
|
144 |
.Dl "cut -d : -f 1,7 /etc/passwd"
|
|
|
145 |
.Pp
|
|
|
146 |
Show the names and login times of the currently logged in users:
|
|
|
147 |
.Pp
|
|
|
148 |
.Dl "who | cut -c 1-16,26-38"
|
|
|
149 |
.Sh SEE ALSO
|
|
|
150 |
.Xr colrm 1 ,
|
|
|
151 |
.Xr paste 1
|
|
|
152 |
.Sh STANDARDS
|
|
|
153 |
The
|
|
|
154 |
.Nm
|
|
|
155 |
utility conforms to
|
|
|
156 |
.St -p1003.2-92 .
|
|
|
157 |
.Pp
|
|
|
158 |
The
|
|
|
159 |
.Fl w
|
|
|
160 |
flag is an extension to the specification.
|
|
|
161 |
.Sh HISTORY
|
|
|
162 |
A
|
|
|
163 |
.Nm
|
|
|
164 |
command appeared in
|
|
|
165 |
.Tn AT&T
|
|
|
166 |
System III
|
|
|
167 |
.Ux .
|