cut (output columns from files)

This command is used to “cut out” columns from plain text tables. Have a look at this example:

mount | cut -d “ ” -f 3

This will extract the third column from mount's output. The mount command outputs a listing of the form:

DEVICE on DIR type TYPE (OPTIONS)

This is basically a table with six columns. The command cut -f 3 will limit output to the third column or “field”. The -d option sets the table delimiter. In the command shown above, a whitespace character (“ ”) is specified as a delimiter. By default, cut assumes that table columns are delimited by a tab stop.

Here is another example of how cut may be put to use:

cut -d : -f 3 /etc/group

This will extract the third column from the file /etc/group, providing a list of group numbers. The file's columns are delimited by a colon (:).