O'Reilly logo

Linux Shell Scripting Essentials by Sinny Kumari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Cut-based selection

We can also select a text from each line of single/multiple files using the cut command. The cut command allows us to select a column based on delimiters. By default, TAB is used as delimiter. We can also select a portion of the text in a line by specifying the characters or range. The syntax is as follows:

cut OPTION [FILE …]

The cut command works on the single and multiple files. By default, the output is printed on stdout.

The options for the cut command are explained in the following table:

Option

Description

-b LIST

This selects bytes that are specified in LIST.

-c LIST

This selects characters that are specified in LIST.

-d DELIM

This uses delimiter as DELIM instead of TAB. It also prints lines that don't ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required