~nabijaczleweli/voreutils

ref: 58932cecd7b0d91af0436de15456a6e875a968b9 voreutils/man1/cut.1.html -rw-r--r-- 14.4 KiB
58932cec — наб autouploader Manpage update by job 786675 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<!DOCTYPE html>
<html>
<!-- This is an automatically generated file.  Do not edit.
   SPDX-License-Identifier: 0BSD
   -->
<head>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <link rel="stylesheet" href="../style.css" type="text/css" media="all"/>
  <title>CUT(1)</title>
</head>
<body>
<table class="head">
  <tr>
    <td class="head-ltitle">CUT(1)</td>
    <td class="head-vol">General Commands Manual</td>
    <td class="head-rtitle">CUT(1)</td>
  </tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">cut</code> &#x2014; <span class="Nd">extract
    bytes, characters, or fields</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<table class="Nm">
  <tr>
    <td><code class="Nm">cut</code></td>
    <td><code class="Fl">-b</code>
      <var class="Ar">range</var>[,<var class="Ar">range</var>]&#x2026;
      [<code class="Fl">-Czn</code>] [<var class="Ar">file</var>]&#x2026;</td>
  </tr>
</table>
<table class="Nm">
  <tr>
    <td><code class="Nm">cut</code></td>
    <td><code class="Fl">-c</code>
      <var class="Ar">range</var>[,<var class="Ar">range</var>]&#x2026;
      [<code class="Fl">-Cz</code>] [<var class="Ar">file</var>]&#x2026;</td>
  </tr>
</table>
<table class="Nm">
  <tr>
    <td><code class="Nm">cut</code></td>
    <td><code class="Fl">-f</code>
      <var class="Ar">range</var>[,<var class="Ar">range</var>]&#x2026;
      [<code class="Fl">-Czs</code>] [<code class="Fl">-d</code>
      <var class="Ar">elimiter</var>] [<code class="Fl">-O</code>
      <var class="Ar">out-delimiter</var>]
      [<var class="Ar">file</var>]&#x2026;</td>
  </tr>
</table>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">Copies bytes, characters, or fields specified by
    <var class="Ar">range</var>s from each line of the input
    <var class="Ar">file</var>s (standard input stream if
    &quot;<b class="Sy">-</b>&quot;, the default), to the standard output
    stream.</p>
<p class="Pp"><var class="Ar">range</var>s can be separated by commas or spaces,
    and each can be in the format:</p>
<div class="Bd-indent">
<dl class="Bl-tag Bl-compact">
  <dt><var class="Ar">number</var></dt>
  <dd>{<var class="Ar">number</var>}</dd>
  <dt><var class="Ar">from</var><code class="Cm">-</code></dt>
  <dd>[<var class="Ar">from</var>, <span class="No">&#x221E;</span>)</dd>
  <dt><var class="Ar">from</var><code class="Cm">-</code><var class="Ar">to</var></dt>
  <dd>[<var class="Ar">from</var>, <var class="Ar">to</var>]</dd>
  <dt><code class="Li">&#x00A0;&#x00A0;&#x00A0;&#x00A0;</code><code class="Cm">-</code><var class="Ar">to</var></dt>
  <dd>[<code class="Li">1</code>, <var class="Ar">to</var>]</dd>
</dl>
</div>
Indices are <i class="Em">1</i>-based, and a union is taken of all
  <var class="Ar">range</var>s. Empty <var class="Ar">range</var>s
  (<var class="Ar">from</var> <span class="No">&lt;</span>
  <var class="Ar">to</var>) are invalid.
<p class="Pp">With <code class="Fl">-b</code>, bytes are extracted; with
    <code class="Fl">-n</code>, characters are never interrupted mid-sequence,
    with rounding preferred down (see
    <a class="Sx" href="#EXAMPLES">EXAMPLES</a>). With complementary
    <var class="Ar">range</var>s (like <var class="Ar">-20</var>
    <span class="No">and</span> <var class="Ar">21-</var>), each character is
    guaranteed to only be output once.</p>
<p class="Pp">With <code class="Fl">-c</code>, characters in the current locale
    are extracted, and invalid sequences are ignored.</p>
<p class="Pp">With <code class="Fl">-f</code>,
    <code class="Fl">-d</code>-delimited fields are extracted. If more than one
    field is matched in a line, they are merged with <code class="Fl">-O</code>.
    Lines that don't contain a delimiter are passed through verbatim, unless
    <code class="Fl">-s</code>, in which case they're removed.</p>
<p class="Pp">The newline (NUL with <code class="Fl">-z</code>) is never matched
    and always printed (unless the entire line was removed with
    <code class="Fl">-fs</code>).</p>
</section>
<section class="Sh">
<h1 class="Sh" id="OPTIONS"><a class="permalink" href="#OPTIONS">OPTIONS</a></h1>
<dl class="Bl-tag Bl-compact">
  <dt id="b"><a class="permalink" href="#b"><code class="Fl">-b</code></a>,
    <code class="Fl">--bytes</code>=<var class="Ar">range</var>[,<var class="Ar">range</var>]&#x2026;</dt>
  <dd>Extract bytes.</dd>
  <dt id="n"><a class="permalink" href="#n"><code class="Fl">-n</code></a></dt>
  <dd>Don't interrupt multi-byte character sequences.
    <p class="Pp"></p>
  </dd>
  <dt id="c"><a class="permalink" href="#c"><code class="Fl">-c</code></a>,
    <code class="Fl">--characters</code>=<var class="Ar">range</var>[,<var class="Ar">range</var>]&#x2026;</dt>
  <dd>Extract characters in the current locale.
    <p class="Pp"></p>
  </dd>
  <dt id="f"><a class="permalink" href="#f"><code class="Fl">-f</code></a>,
    <code class="Fl">--fields</code>=<var class="Ar">range</var>[,<var class="Ar">range</var>]&#x2026;</dt>
  <dd>Extract delimited fields.</dd>
  <dt id="d"><a class="permalink" href="#d"><code class="Fl">-d</code></a>,
    <code class="Fl">--delimiter</code>=<var class="Ar">delim</var></dt>
  <dd>Split fields on <var class="Ar">delim</var>. Default: tab.</dd>
  <dt id="O"><a class="permalink" href="#O"><code class="Fl">-O</code></a>,
    <code class="Fl">--output-delimiter</code>=<var class="Ar">out-delim</var></dt>
  <dd>When merging fields for output, use <var class="Ar">out-delim</var>.
      Default: <var class="Ar">delim</var>.</dd>
  <dt id="s"><a class="permalink" href="#s"><code class="Fl">-s</code></a>,
    <code class="Fl">--only-delimited</code></dt>
  <dd>Remove lines that don't contain <var class="Ar">delim</var> instead of
      passing them through.
    <p class="Pp"></p>
  </dd>
  <dt id="C"><a class="permalink" href="#C"><code class="Fl">-C</code></a>,
    <code class="Fl">--complement</code></dt>
  <dd>Invert <var class="Ar">range</var>s: select all
      <a class="permalink" href="#but"><i class="Em" id="but">but</i></a> what
      they match ([<b class="Sy">1</b>, <span class="No">&#x221E;</span>)
      <span class="No">- &#x03A3;</span><var class="Ar">range</var>). For the
      purposes of <code class="Fl">-n</code>, the most minimal set of
      <var class="Ar">range</var>s is constructed.</dd>
  <dt id="z"><a class="permalink" href="#z"><code class="Fl">-z</code></a>,
    <code class="Fl">--zero-terminated</code></dt>
  <dd>Line separator is NUL, not newline.</dd>
</dl>
</section>
<section class="Sh">
<h1 class="Sh" id="EXIT_STATUS"><a class="permalink" href="#EXIT_STATUS">EXIT
  STATUS</a></h1>
<p class="Pp"><b class="Sy">1</b> if a <var class="Ar">file</var> couldn't be
    opened.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="EXAMPLES"><a class="permalink" href="#EXAMPLES">EXAMPLES</a></h1>
<div class="Bd Li">
<pre><code class="Li">$</code> <code class="Nm">printf</code> <code class="Li">'\x01\x02\x03\x04\0\x05\x06\x07' |</code> <code class="Nm"></code></pre>
cut <code class="Fl">-zb</code> <var class="Ar">1,3-</var>
  <code class="Li">|</code> <code class="Nm">hexdump</code>
  <code class="Fl">-C</code>
00000000 01 03 04 00 05 07 00 |.......|
00000007

<code class="Li">$</code> <code class="Ic">for</code> <var class="Ar">i</var>
  <code class="Ic">in</code>
  <code class="Li">$(</code><code class="Nm">seq</code>
  <var class="Ar">10</var><code class="Li">);</code> <code class="Ic">do</code>
<code class="Li">&gt; </code> <code class="Nm">echo</code>
  <code class="Li">&quot;-$i;$((i+1))-&quot; |</code>
  <code class="Nm">paste</code> <span class="Pa">-</span>
  <code class="Li">\</code>
<code class="Li">&gt; &lt;(</code><code class="Nm">printf</code>
  <code class="Li">'&#x044F;&#x0439;&#x0446;&#x043E;\n&#x042F;&#x0419;&#x0426;&#x041E;'
  |</code> <code class="Nm">cut</code> <code class="Fl">-nb</code>
  <var class="Ar">-$i</var><code class="Li">) \</code>
<code class="Li">&gt; &lt;(</code><code class="Nm">printf</code>
  <code class="Li">'&#x044F;&#x0439;&#x0446;&#x043E;\n&#x042F;&#x0419;&#x0426;&#x041E;'
  |</code> <code class="Nm">cut</code> <code class="Fl">-nb</code>
  <var class="Ar">$((i+1))-</var><code class="Li">)</code>
<code class="Li">&gt;</code> <code class="Ic">done</code>
-1;2- &#x044F;&#x0439;&#x0446;&#x043E;
 &#x042F;&#x0419;&#x0426;&#x041E;
-2;3- &#x044F; &#x0439;&#x0446;&#x043E;
 &#x042F; &#x0419;&#x0426;&#x041E;
-3;4- &#x044F; &#x0439;&#x0446;&#x043E;
 &#x042F; &#x0419;&#x0426;&#x041E;
-4;5- &#x044F;&#x0439; &#x0446;&#x043E;
 &#x042F;&#x0419; &#x0426;&#x041E;
-5;6- &#x044F;&#x0439; &#x0446;&#x043E;
 &#x042F;&#x0419; &#x0426;&#x041E;
-6;7- &#x044F;&#x0439;&#x0446; &#x043E;
 &#x042F;&#x0419;&#x0426; &#x041E;
-7;8- &#x044F;&#x0439;&#x0446; &#x043E;
 &#x042F;&#x0419;&#x0426; &#x041E;
-8;9- &#x044F;&#x0439;&#x0446;&#x043E;
 &#x042F;&#x0419;&#x0426;&#x041E;
-9;10- &#x044F;&#x0439;&#x0446;&#x043E;
 &#x042F;&#x0419;&#x0426;&#x041E;
-10;11- &#x044F;&#x0439;&#x0446;&#x043E;
 &#x042F;&#x0419;&#x0426;&#x041E;</div>
<p class="Pp"></p>
<div class="Bd Li">
<pre><code class="Li">$</code> <code class="Nm">printf</code> <code class="Li">'&#x044F;&#x0439;&#x0446;&#x043E;\n&#x042F;&#x0419;&#x0426;&#x041E;' |</code> <code class="Nm"></code></pre>
cut <code class="Fl">-c</code> <var class="Ar">1,3-</var>
&#x044F;&#x0446;&#x043E;
&#x042F;&#x0426;&#x041E;</div>
<p class="Pp"></p>
<div class="Bd Li">
<pre># name, IDs, homedir, shell, ...
<code class="Li">$</code> <code class="Nm"></code></pre>
cut <code class="Fl">-f</code> <var class="Ar">1,3-4,6-</var>
  <code class="Fl">-d</code><var class="Ar">:</var>
  <code class="Fl">-O</code><code class="Li">&quot;$(</code><code class="Nm">printf</code>
  <code class="Li">'\t')&quot;</code> <span class="Pa">/etc/passwd</span>
root 0 0 /root /bin/bash
bin 2 2 /bin /usr/sbin/nologin
irc 39 39 /var/run/ircd /usr/sbin/nologin
cicada 1000 100 /home/cicada /bin/bash
nobody 65534 65534 /nonexistent /usr/sbin/nologin
# Everything else: password and GNATS
<code class="Li">$</code> <code class="Nm"></code>cut
  <code class="Fl">-Cf</code> <var class="Ar">1,3-4,6-</var>
  <code class="Fl">-d</code><var class="Ar">:</var>
  <code class="Fl">-O</code><code class="Li">&quot;$(</code><code class="Nm">printf</code>
  <code class="Li">'\t')&quot;</code> <span class="Pa">/etc/passwd</span>
x root
x bin
x ircd
x Cicadum,,,
x nobody</div>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
  ALSO</a></h1>
<p class="Pp"><a class="Xr" href="../man1/paste.1.html">paste(1)</a>,
    <a class="Xr" href="https://manpages.debian.org/bullseye/mbrlen.3">mbrlen(3)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="STANDARDS"><a class="permalink" href="#STANDARDS">STANDARDS</a></h1>
<p class="Pp">Conforms to <span class="St">IEEE Std 1003.1-2008
    (&#x201C;POSIX.1&#x201D;)</span>; <code class="Fl">-CzO</code> are
    extensions, compatible with the GNU system (the short versions of
    <code class="Fl">-CO</code> <span class="No">are not available
    there</span>). Allowing <code class="Fl">-d</code> longer than one character
    is an extension &#x2014; some nonconformant implementations only allow a
    single byte (the GNU system) or only use the first byte of the
    <var class="Ar">delim</var> (<span class="Ux">NetBSD</span>,
    <span class="Ux">OpenBSD</span>).</p>
<p class="Pp">&#x0422;his implementation allows all formats allowed by
    <a class="Xr" href="https://manpages.debian.org/bullseye/strtoull.3">strtoull(3)</a>
    in <var class="Ar">range</var>s, but some others (the
    <span class="Ux">BSD</span>, the GNU system) only allow decimal digits.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
<p class="Pp">Written by Gottfried W. R. Luderer with the corresponding
    <a class="Xr" href="../man1/paste.1.html">paste(1)</a>, appeared
    mostly-fully-formed in CB-UNIX at or before 2.1 as
    <a class="Xr" href="../man1/cut.1.html">cut(1)</a>:</p>
<div class="Bd Bd-indent">cut - cut out selected fields of each line of a
  file</div>
Supporting <code class="Fl">-c</code> and <code class="Fl">-fds</code>, with
  <code class="Fl">-c</code> handling a single ASCII backspace
  (<a class="permalink" href="#0x08"><b class="Sy" id="0x08">0x08</b></a>)
  &quot;as produced by nroff&quot; by not considering it and the next character
  as being in the position of the previous one (i.e.
  <code class="Cm">printf</code> <code class="Li">'abc\bdef\bgh\n' |</code>
  <code class="Nm">cut</code> <code class="Fl">-c</code><var class="Ar">3</var>
  <span class="No">is</span> &#x2018;<code class="Li">c\bd</code>&#x2019;,
  <code class="Li">|</code> <code class="Nm">cut</code>
  <code class="Fl">-c</code><var class="Ar">4</var> <span class="No">is</span>
  &#x2018;<code class="Li">e</code>&#x2019;, &amp;c.).
  <code class="Fl">-c</code> is equivalent, with the single-byte characters of
  then, to today's <code class="Fl">-b</code>. It also notes that the
  <var class="Ar">range</var>s are &quot;as in the <code class="Fl">-o</code>
  <span class="No">option to</span>
  <a class="permalink" href="#nroff"><i class="Em" id="nroff">nroff</i></a>/<a class="permalink" href="#troff"><i class="Em" id="troff">troff</i></a>
  <span class="No">for page ranges</span>&quot;. CB-UNIX was, among others, the
  basis for <span class="Ux">AT&amp;T System&#x00A0;III UNIX</span>, where it
  first saw light outside of AT&amp;T.
<p class="Pp">A bug in <span class="Ux">AT&amp;T System&#x00A0;V
    Release&#x00A0;2 UNIX</span>, caused by a transition to reading in blocks,
    breaks the backspace behaviour.</p>
<p class="Pp"><span class="Ux">AT&amp;T System&#x00A0;V Release&#x00A0;3
    UNIX</span> fixes that, and allows &quot;<b class="Sy">-</b>&quot; as
    <var class="Ar">file</var> to mean the standard input stream.</p>
<p class="Pp"><span class="St">IEEE Std 1003.2-1992
    (&#x201C;POSIX.2&#x201D;)</span> created <code class="Fl">-b</code> and
    <code class="Fl">-n</code>, as part of support for multi-byte character
    encodings.</p>
<p class="Pp">A CB-UNIX-compatible <code class="Nm">cut</code> appears in
    <span class="Ux">4.3BSD-Reno</span>.</p>
</section>
</div>
<table class="foot">
  <tr>
    <td class="foot-date">June 23, 2022</td>
    <td class="foot-os">voreutils pre-v0.0.0-latest</td>
  </tr>
</table>
</body>
</html>