Print this page
13507 some man pages need update following 13405
6308 some man pages are obsolete after moving to ksh builtins
   1 CUT(1)                           User Commands                          CUT(1)
   2 
   3 
   4 
   5 NAME
   6        cut - cut out selected fields of each line of a file
   7 
   8 SYNOPSIS
   9        cut -b list [-n] [file]...
  10 

  11 
  12        cut -c list [file]...
  13 
  14 
  15        cut -f list [-d delim] [-s] [file]...
  16 
  17 
  18 DESCRIPTION
  19        Use the cut utility to cut out columns from a table or fields from each
  20        line of a file; in data base parlance, it implements the projection of
  21        a relation. The fields as specified by list can be fixed length, that
  22        is, character positions as on a punched card (-c option) or the length
  23        can vary from line to line and be marked with a field delimiter
  24        character like TAB (-f option). cut can be used as a filter.
  25 
  26 
  27        Either the -b, -c, or -f option must be specified.
  28 
  29 
  30        Use grep(1) to make horizontal ``cuts'' (by context) through a file, or
  31        paste(1) to put files together column-wise (that is, horizontally). To
  32        reorder columns in a table, use cut and paste.
  33 
  34 OPTIONS
  35        The following options are supported:
  36 
  37        list
  38                     A comma-separated or blank-character-separated list of
  39                     integer field numbers (in increasing order), with optional
  40                     - to indicate ranges (for instance, 1,4,7; 1-3,8; -5,10
  41                     (short for 1-5,10); or 3- (short for third through last
  42                     field)).
  43 
  44 
  45        -b list
  46                     The list following -b specifies byte positions (for
  47                     instance, -b1-72 would pass the first 72 bytes of each
  48                     line). When -b and -n are used together, list is adjusted
  49                     so that no multi-byte character is split.
  50 
  51 
  52        -c list
  53                     The list following -c specifies character positions (for
  54                     instance, -c1-72 would pass the first 72 characters of
  55                     each line).
  56 
  57 
  58        -d delim
  59                     The character following -d is the field delimiter (-f
  60                     option only).  Default is tab. Space or other characters
  61                     with special meaning to the shell must be quoted. delim
  62                     can be a multi-byte character.
  63 
  64 
  65        -f list
  66                     The list following -f is a list of fields assumed to be
  67                     separated in the file by a delimiter character (see -d );
  68                     for instance, -f1,7 copies the first and seventh field
  69                     only. Lines with no field delimiters will be passed
  70                     through intact (useful for table subheadings), unless -s
  71                     is specified.
  72 






  73 
  74        -n
  75                     Do not split characters. When -b list and -n are used
  76                     together, list is adjusted so that no multi-byte character
  77                     is split.
  78 



  79 
  80        -s
  81                     Suppresses lines with no delimiter characters in case of
  82                     -f option.  Unless specified, lines with no delimiters
  83                     will be passed through untouched.
  84 





  85 





  86 OPERANDS
  87        The following operands are supported:
  88 
  89        file
  90                 A path name of an input file. If no file operands are
  91                 specified, or if a file operand is -, the standard input will
  92                 be used.
  93 


  94 
  95 USAGE
  96        See largefile(5) for the description of the behavior of cut when
  97        encountering files greater than or equal to 2 Gbyte (2^31 bytes).
  98 
  99 EXAMPLES
 100        Example 1 Mapping user IDs
 101 
 102 
 103        A mapping of user IDs to names follows:
 104 

 105 
 106          example% cut -d: -f1,5 /etc/passwd
 107 
 108 
 109 
 110        Example 2 Setting current login name
 111 
 112 
 113        To set name to current login name:
 114 

 115 
 116          example$ name=`who am i | cut -f1 -d' '`
 117 
 118 
 119 
 120 ENVIRONMENT VARIABLES
 121        See environ(5) for descriptions of the following environment variables
 122        that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
 123        and NLSPATH.
 124 
 125 EXIT STATUS
 126        The following exit values are returned:

 127 
 128        0
 129               All input files were output successfully.
 130 
 131 
 132        >0
 133               An error occurred.
 134 
 135 
 136 ATTRIBUTES
 137        See attributes(5) for descriptions of the following attributes:
 138 
 139 
 140 
 141 
 142        +--------------------+-----------------+
 143        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 144        +--------------------+-----------------+
 145        |CSI                 | Enabled         |
 146        +--------------------+-----------------+
 147        |Interface Stability | Standard        |
 148        +--------------------+-----------------+
 149 
 150 SEE ALSO
 151        grep(1), paste(1), attributes(5), environ(5), largefile(5),
 152        standards(5)
 153 
 154 DIAGNOSTICS
 155        cut: -n may only be used with -b
 156 
 157 
 158 
 159 
 160        cut: -d may only be used with -f
 161 
 162 
 163 
 164 
 165        cut: -s may only be used with -f
 166 
 167 
 168 
 169 
 170        cut: cannot open <file>
 171 
 172            Either file cannot be read or does not exist.  If multiple files
 173            are present, processing continues.
 174 
 175 
 176        cut: no delimiter specified
 177 
 178            Missing delim on -d option.
 179 
 180 
 181        cut: invalid delimiter
 182 
 183 
 184 
 185 
 186        cut: no list specified
 187 
 188            Missing list on -b, -c, or -f option.
 189 
 190 
 191        cut: invalid range specifier
 192 
 193 
 194 
 195 
 196        cut: too many ranges specified
 197 
 198 
 199 
 200 
 201        cut: range must be increasing
 202 
 203 
 204 
 205 
 206        cut: invalid character in range
 207 
 208 
 209 
 210 
 211        cut: internal error processing input
 212 
 213 
 214 
 215 
 216        cut: invalid multibyte character
 217 
 218 
 219 
 220 
 221        cut: unable to allocate enough memory
 222 
 223 
 224 
 225 
 226 
 227 
 228                                 April 29, 1999                          CUT(1)
   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