Bash Using Cut

  • Read
  • Discuss

The cut command in bash is used to extract specific fields or characters from a file or input. It takes input from either a file or standard input, and based on the specified options, it can extract characters at a specified position, fields separated by a delimiter, or bytes.

The basic syntax for using cut is:


A few commonly used options for cut are:

  • -d followed by a delimiter character to specify the delimiter to use for separating fields.
  • -f followed by a list of field numbers to extract specific fields from the input.
  • -c followed by a list of character numbers to extract specific characters from the input.

For example, to extract the first and third fields from a file “file.txt” separated by a colon, use the following command:

cut -d ':' -f 1,3 file.txt

Leave a Reply

Scroll to Top