Text Processing

cut

Extracts sections from each line.

cut selects character ranges or delimiter-separated fields from text.

Syntax
cut [options] [file...]

Arguments explained

  • -d sets a delimiter.
  • -f selects fields.
  • -c selects character positions.

Common examples

Extract usernames
cut -d: -f1 /etc/passwd

Prints the first colon-separated field.

Show first characters
cut -c1-8 file.txt

Prints characters 1 through 8 of each line.

cut Command
FieldDetails
Commandcut
CategoryText Processing
Primary useExtracts sections from each line.
Syntaxcut [options] [file...]