cut

cut

Purpose

Copy selected parts of each line of text from a file to standard output.

Syntax

cut [options]

Options

-b list extracts the characters at positions specified in the list.

-f list extracts the fields (assumed to be Tab-separated) specified in list.

-d char specifies the character that delimits the fields (the default is Tab).

-s skips lines that do not contain delimited fields (see the -f option).

Description

The cut command extracts specified parts from each line of text in a file and writes those lines out to standard output. You can extract either a range of characters (specified by their positions) from each line or specific fields, where the fields are separated by a special character such as the Tab. For example, to extract characters 1 through 11 and the 56th character onward from a detailed directory listing, use the following command:

ls -l | cut -b 1-11,56- | more total 2056 -rw-r-r- a2ps.cfg -rw-r-r- a2ps-site.cfg -rw-r-r- adjtime drwxr-xr-x aep -rw-r-r- aep.conf -rw-r-r- aeplog.conf drwxr-xr-x alchemist -rw-r-r- aliases -rw-r--- aliases.db (... lines deleted)