1 CUT(1) User Commands CUT(1) 2 3 NAME 4 cut - cut out selected columns or fields of each line of a file 5 6 SYNOPSIS 7 cut -b list [-nN] [-r reclen] [file]... 8 9 cut -c list [-N] [-r reclen] [file]... 10 11 cut -f list [-s] [-d delim] [-D ldelim] [file]... 12 13 DESCRIPTION 14 Use the cut utility to cut out columns from a table or fields from each 15 line of a file. In database parlance, it implements the projection of a 16 relation. The fields as specified by list can be fixed length, that is, 17 character positions as on a punched card (-c option) or the length can 18 vary from line to line and be marked with a field delimiter character 19 such as TAB (-f option). cut can be used as a filter. 20 21 Either the -b, -c, or -f option must be specified. 22 23 Use grep(1) to make horizontal cuts (by context) through a file, or 24 paste(1) to put files together column-wise (that is, horizontally). To 25 reorder columns in a table, use cut and paste(1). 26 27 OPTIONS 28 The following options are supported: 29 30 -b list, --bytes=list 31 The list following -b specifies byte positions (for 32 instance, -b 1-72 would pass the first 72 bytes of each 33 line). When -b and -n are used together, list is adjusted 34 so that no multi-byte character is split. 35 36 -c list, --characters=list 37 The list following -c specifies character positions (for 38 instance, -c 1-72 would pass the first 72 characters of 39 each line). 40 41 -d delim, --delimiter=delim 42 The character following -d is the field delimiter (-f 43 option only); the default is the TAB character. Space or 44 other characters with special meaning to the shell must be 45 quoted. delim can be a multi-byte character. 46 47 -f list, --fields=list 48 The list following -f is a list of fields assumed to be 49 separated in the file by a delimiter character (see -d); 50 for instance, -f 1,7 copies the first and seventh field 51 only. Lines with no field delimiters will be passed 52 through intact (useful for table subheadings), unless -s is 53 specified. 54 55 -n, --split, --nosplit 56 Controls whether multi-byte characters are split with the 57 -b option. The default is to split characters and this can 58 be disabled with the -n or --nosplit flag. Unless 59 specified, lines with no delimiters will be passed through 60 untouched. 61 62 -r reclen, -R reclen, --reclen=reclen 63 If reclen is > 0, the input will be read as fixed length 64 records of length reclen when used with the -b or -c 65 options. 66 67 -s, --suppress, --only-delimited 68 Suppress lines which do not contain any delimiter 69 characters (-f option only). 70 71 -D ldelim, --line-delimiter=ldelim, --output-delimiter=ldelim 72 The line delimiter for the -f option is set to ldelim. The 73 default is the newline character. 74 75 -N, --newline, --nonewline 76 Controls whether to output a new-line at the end of each 77 record when used with the -b or -c options. This is on by 78 default; -N turns it off and is the same as specifying 79 --nonewline. 80 81 In the above options, list is a comma-separated or blank-character- 82 separated list of integer field, byte or character numbers (in increasing 83 order), with optional - to indicate ranges (for instance, 1,4,7; 1-3,8; 84 -5,10 (short for 1-5,10); or 3- (short for third through last field). ) 85 86 OPERANDS 87 The following operands are supported: 88 89 file A path name of an input file. If no file operands are 90 specified, or if a file operand is -, the standard input 91 will be used. 92 93 EXIT STATUS 94 0 All input files were output successfully. 95 96 >0 An error occurred. 97 98 EXAMPLES 99 Example 1 Mapping user IDs 100 101 A mapping of user IDs to names follows: 102 103 $ cut -d: -f1,5 /etc/passwd 104 105 Example 2 Setting current login name 106 107 To set name to current login name: 108 109 $ name=`who am i | cut -f1 -d' '` 110 111 ENVIRONMENT VARIABLES 112 See environ(5) for descriptions of the following environment variables 113 that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, 114 LC_NUMERIC, and NLSPATH. 115 116 INTERFACE STABILITY 117 The command line interface of cut is Committed. The output of cut is 118 Committed. 119 120 SEE ALSO 121 grep(1), paste(1), attributes(5), environ(5), largefile(5), standards(5) 122 123 illumos February 9, 2021 illumos