English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux cut command

Linux Command大全

The Linux cut command is used to display the first num1 to num2 text.

Syntax

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

Usage Instructions:

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

If the File parameter is not specified, the cut command will read from standard input. It must specify -b,-c or -f flag one of them.

parameter:

  • -b: Split by byte. These byte positions will ignore the boundaries of multibyte characters unless -n flag.
  • -c: Split by character.
  • -d: Custom delimiter, default is tab.
  • -f: With-d: Specify which region to display. Only used with
  • -n: Cancel the split of multibyte characters. Only used with -b flag together. If the last byte of the character falls within -b flag of the List parameter indicates
    within the range, the character will be written out; otherwise, the character will be excluded

Online Examples

When you execute the who command, it will output 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 the3bytes, like this:

$ who|cut -b 3
c
c

Linux Command大全