Exploring cut - Linux Commands

| 3 min read

What is the cut Command in Linux?

The cut command is used to extract sections from each line of files or standard input. It allows you to cut out specific fields or characters from text, which is useful for processing and analyzing data. It is often employed in shell scripts or command-line operations to manipulate text data efficiently.

Basic syntax:

cut [option] [file]

Example:

cut -d ',' -f 1,3 file-name

Options

OptionDescription
-b, —bytesSelect only the bytes specified by the list
-c, —charactersSelect only the characters specified by the list
-d, —delimiterSpecify a delimiter to use (default is TAB)
-f, —fieldsSpecify the fields to extract, using the delimiter
-s, —only-delimitedSuppress lines that do not contain the delimiter
-z, —zero-terminatedTreat input lines as terminated by a null character (instead of a newline)

Additional Help

You can explore more by using the commands:

cut --help
# or
man cut

Thank you!

Thank you for your time and for reading this!