1.\" $NetBSD: cut.1,v 1.19 2025/03/04 03:54:19 gutteridge Exp $ 2.\" 3.\" Copyright (c) 1989, 1990, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" the Institute of Electrical and Electronics Engineers, Inc. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. Neither the name of the University nor the names of its contributors 18.\" may be used to endorse or promote products derived from this software 19.\" without specific prior written permission. 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31.\" SUCH DAMAGE. 32.\" 33.\" @(#)cut.1 8.1 (Berkeley) 6/6/93 34.\" 35.Dd March 4, 2025 36.Dt CUT 1 37.Os 38.Sh NAME 39.Nm cut 40.Nd select portions of each line of a file 41.Sh SYNOPSIS 42.Nm 43.Fl b Ar list 44.Op Fl n 45.Op Ar 46.Nm 47.Fl c Ar list 48.Op Ar 49.Nm 50.Fl f Ar list 51.Op Fl d Ar string 52.Op Fl s 53.Op Ar 54.Sh DESCRIPTION 55The 56.Nm 57utility selects portions of each line (as specified by 58.Ar list ) 59from each 60.Ar file 61and writes them to the 62standard output. 63If the 64.Ar file 65argument is a single dash 66.Pq Sq - 67or no 68.Ar file 69arguments were specified, lines are read from the standard input. 70The items specified by 71.Ar list 72can be in terms of column position or in terms of fields delimited 73by a special character. 74Column and field numbering start from 1. 75.Pp 76.Ar list 77is a comma or whitespace separated set of increasing numbers and/or 78number ranges. 79Number ranges consist of a number, a dash 80.Pq Li \- , 81and a second number 82and select the columns or fields from the first number to the second, 83inclusive. 84Numbers or number ranges may be preceded by a dash, which selects all 85columns or fields from 1 to the first number. 86Numbers or number ranges may be followed by a dash, which selects all 87columns or fields from the last number to the end of the line. 88Numbers and number ranges may be repeated, overlapping, and in any order. 89It is not an error to select columns or fields not present in the 90input line. 91.Pp 92The options are as follows: 93.Bl -tag -width Fl 94.It Fl b Ar list 95.Ar list 96specifies byte positions. 97.It Fl c Ar list 98.Ar list 99specifies character positions. 100.It Fl d Ar string 101Use the first character of 102.Ar string 103as the field delimiter character. 104The default is the 105.Aq TAB 106character. 107.It Fl f Ar list 108.Ar list 109specifies fields, separated by the field delimiter character. 110The selected fields are output, 111separated by the field delimiter character. 112.It Fl n 113Do not split multi-byte characters when the 114.Fl b 115option is used. 116Characters will only be output if at least one byte is selected, and, 117after a prefix of zero or more unselected bytes, the rest of the bytes 118that form the character are selected. 119.It Fl s 120Suppress lines with no field delimiter characters. 121Unless specified, lines with no delimiters are passed through unmodified. 122.El 123.Sh ENVIRONMENT 124The 125.Ev LANG , 126.Ev LC_ALL , 127and 128.Ev LC_CTYPE 129environment variables affect the execution of 130.Nm 131if the 132.Fl n 133option is specified. 134Their effect is described in 135.Xr environ 7 . 136.Sh EXIT STATUS 137.Ex -std 138.Sh SEE ALSO 139.Xr paste 1 140.Sh STANDARDS 141The 142.Nm 143utility conforms to 144.St -p1003.2-92 . 145