field - extract selected fields from each line
field [−abem] [−d delims] [−o delims] [−f fields] [file ...]
field [−abem] [−d delims] [−o delims] fields [file ...]
The field filter writes parts of each input line selected by a list of fields.
A list of fields is a comma-separated list of field numbers or field ranges. A field range consists of an optional starting field number, a dash, and an optional ending field number. If the starting field number is omitted, then the range begins with the first field; if the ending field number is omitted, then the range ends with the last field on the input line. Input fields are numbered beginning with 1; a field number of 0 produces an empty field in the output.
The options are as follows:
The cut(1) utility, introduced in System III UNIX™, performs a somewhat similar function. The major differences are, first, that field by default considers each line to consist of fields separated by sequences of white space, while cut can only split on every instance of a single delimiter character; second, that field currently operates only on delimited fields, and not on character or byte ranges; and third, that field writes input fields in the order given by its fields list, and thus can be used to reorder or repeat input fields.
Examples:
ls -l | field 9,5
field -a -d: 1,5 /etc/passwd
cut(1) , sort(1)