Linux cut Command
Linux cut Command
Linux cut command displays each line from the beginning date num1 to num2 text.
grammar
cut [-bn] [file] cut [-c] [file] cut [-df] [file]
Instructions for use:
cut from each command line cut bytes, characters, and fields file and writes these bytes, characters, or fields to standard output.
If you do not specify a File parameter, cut command reads standard input. You must specify the -b, -c, or -f flag.
parameter:
- -b: divided in units of bytes. These byte positions ignore multibyte character boundaries unless the -n flag is also specified.
- -c: the characters split units.
- -d: custom delimiter, the default tabs.
- -f: used with -d, which specifies the display area.
- -n: Cancel split multi-byte characters. Only the -b flag. If the last-byte characters within a range of falls by the List parameter -b flag indication of the character will be written out; otherwise, the character will be excluded
Examples
When you execute the who command, output similar to the following topics:
$ 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 first three bytes of each line, so:
$ who|cut -b 3 c c