How to use Linux cut Command

Source: Internet
Author: User

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

Syntax

Cut [-bn] [file]

Cut [-c] [file]

Cut [-df] [file]

Instructions for use:

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

If the File parameter is not specified, the cut command reads the standard input.

-B,-c, or-f must be specified.

Parameters:

  • -B: Split in bytes. These byte locations ignore the multi-byte character boundary unless the-n flag is also specified.
  • -C: separated by characters.
  • -D: custom delimiter. The default delimiter is tab.
  • -F: used with-d to specify the region to display.
  • -N: undelimiter multi-byte characters. It is used only with the-B flag. If the last byte of a character falls within the range indicated by the-B Mark List parameter, the character is written out; otherwise, the character is excluded.

Instance

When you execute the who command, the output is similar to the following:

$ Who

Rocrocket: 0

Rocrocket pts/0 (: 0.0)

Rocrocket pts/1 (: 0.0)

If we want to extract the 3rd bytes of each row, it will be like this:

$ Who | cut-b3

C

C

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.