Slicing and Dicing

The next three programs we will discuss are used to peel columns of text out of files and recombine them in useful ways.

cut—Remove Sections from Each Line of Files

The cut program is used to extract a section of text from a line and output the extracted section to standard output. It can accept multiple file arguments or input from standard input.

Specifying the section of the line to be extracted is somewhat awkward and is specified using the options shown in Table 20-3.

Table 20-3. cut Selection Options

Option

Description

-c char_list

Extract the portion of the line defined by char_list. The list may consist of one or more comma-separated numerical ranges.

-f field_list

Extract one or more fields from the line as defined by field_list ...

Get The Linux Command Line now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.