cut

Basics

  • Display 2nd character from each line in a file

cut -c2 test.txt
  • Display first three characters from each line in a file

cut -c1-3 test.txt
  • Display forst 8 characters from each line in a file

cut -c-8 test.txt
  • Display 1st field when : is the delimeter between the fields in the file

cut -d ':' -f1 test.txt
  • Display the 1st and 6th fields when : is used as a delimiter

cut -d ':' -f1,6 test.txt
  • Display all fields except the 7th field when : is used as the delimiter

cut -d ':' -complement -s -f7 test.txt

Last updated