Easy Tutorial
❮ Linux Comm Userdel Linux Comm Mount ❯

Linux cut Command

Linux Command Manual

The Linux cut command is used to display text from each line starting from position num1 to num2.

Syntax

cut  [-bn] [file]
cut [-c] [file]
cut [-df] [file]

Usage Instructions:

The cut command cuts out sections from each line of files and writes them to the standard output.

If the File parameter is not specified, the cut command reads from the standard input. One of the -b, -c, or -f flags must be specified.

Parameters:

Example

When you execute the who command, it outputs content similar to the following:

$ who
rocrocket :0           2009-01-08 11:07
rocrocket pts/0        2009-01-08 11:23 (:0.0)
rocrocket pts/1        2009-01-08 14:15 (:0.0)

If we want to extract the third byte of each line, we do this:

$ who|cut -b 3
c
c

Linux Command Manual

❮ Linux Comm Userdel Linux Comm Mount ❯