# cut¶

The cut command extracts sections of a file line by line. To do so, one or more fields or one or more characters must be selected.

cut options meaning
-c columns select only the defined characters
-f fields select only the given fields
-d char define the character char as the field delimiter (default: tabulation)
-s do not print lines not containing delimiters

Characters and fields are defined as follows:

N the field or the character N
N- fields or characters from N to the last
-N fields or characters up to N
N-M fields or characters from N to M (included)
N-M,L-P fields or characters from N to M and from L to P
cat > f << END
1234567890
a b c d e.
aa  cc  ee
1234. 789.
END
cut -c 1-4 f
cut -c 1-3,8- f
cut -f 1 f
cut -d" " -f 1 f
cut -d. -f 2 f