Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux cut command

Linux cut command

Linux Command Reference Linux Command Reference

The Linux cut command is used to display the text of each line from num1 to num2, counting from the beginning.

Syntax



cut  [-bn] [file]

cut [-c] [file]

cut [-df] [file]

Usage:

The cut command cuts bytes, characters, and fields from each line of a file and writes them to standard output.

If the File argument is not specified, cut reads from standard input. You must specify one of the -b, -c, or -f flags.

Parameters:

Example

When you run the who command, it outputs something like 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, do this:



$ who|cut -b 3

c

c

Linux Command Reference Linux Command Reference