cut(C) 19 June 1992 cut(C) Name cut - cut out selected fields of each line of a file Syntax cut -c list [ file1 file2 ... ] cut -f list [ -d char ] [ -s ] [ file1 file2 ... ] Description Use cut to cut out columns from a table or fields from each line of a file. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option), or the length can vary from line to line and be marked with a field delimiter character like Tab (-f option). cut can be used as a filter. If no files are given, the standard input is used. The meanings of the options are: list A comma-separated list of integers (in increasing order), with an optional dash (-), indicates ranges, as in the -o option of nroff/troff for page ranges; for example, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field). -c list The list following -c (no space) specifies character positions (for example, -c1-72 would keep the first 72 characters of each line). -f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d); for example, -f1,7 copies the first and seventh field only. Lines with no field de- limiters will be passed through intact (useful for table subhead- ings), unless -s is specified. -d char The character following -d is the field delimiter (-f option only). Default is Tab. Space or other characters with special meaning to the shell must be quoted. -s If the -f option is used, -s suppresses lines with no delimiter characters. Unless specified, lines with no delimiters will be passed through untouched. Either the -c or -f option must be specified. Notes Use grep(C) to make horizontal ``cuts'' (by context) through a file, or paste(C) to put files together horizontally. To reorder columns in a table, use cut and paste. Examples cut -d: -f 1,5 /etc/passwd Maps user ID's to names. name=`who am i | cut -f1 -d" "` Sets name to current login name. See also grep(C), paste(C) Diagnostics line too long A line can have no more than 511 characters or fields. bad list for c / f option Missing -c or -f option or incorrectly specified list. No error occurs if a line has fewer fields than the list calls for. no fields The list is empty. Standards conformance cut is conformant with: AT&T SVID Issue 2; and X/Open Portability Guide, Issue 3, 1989.