Name
cut — stdin stdout - file -- opt --help --version
Synopsis
cut -(b|c|f)range
[options
] [files
]
The cut
command extracts
columns of text from files. A “column” is defined by character
offsets (e.g., the nineteenth character of each line):
$ cut -c19 myfile
or by byte offsets (which are often the same as characters, unless you have multibyte characters in your language):
$ cut -b19 myfile
or by delimited fields (e.g., the fifth field in each line of a comma-delimited file):
$ cut -f5 -d, myfile
You aren’t limited to printing a single column: you can
provide a range (3-16
), a
comma-separated sequence (3,4,5,6,8,16
), or both (3,4,8-16
). For ranges, if you omit the
first number (-16
), a 1 is
assumed (1-16
); if you omit the
last number (5-
), the end of line
is used.
Useful options
|
Use character
|
|
Use character
|
|
Suppress (don’t print) lines that don’t contain the delimiter character. |
Get Linux Pocket Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.