Table of Contents

About

cut is a filter command that

  • works on:
    • the field (word separated by a separator)
    • or character unit
  • select them
  • for each line

Example

Field management

Suppress the first field

Take all fields separated by space after the second one

echo "Hello World to foo" | cut --delimiter ' ' --fields=2-

where:

  • –delimiter specify the delimiter
  • –fields defined the field to chose (ie the columns) and its value 2- means all value from 2

Output:

World to foo

Get the Nth field

echo "Hello World to foo" | cut --delimiter ' ' --fields=2

Output:

World

Suppress the first character

echo foo | cut --characters=2-
# short form
echo foo | cut -c2-
  • Result
oo

where:

  • --characters means that we are manipulating characters
  • 2- means character 2 to the end