You are previewing The Linux Command Line.

The Linux Command Line

Cover of The Linux Command Line by William E. Shotts Jr. Published by No Starch Press

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



-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 ...

The best content for your career. Discover unlimited learning on demand for around $1/day.