29. Linux Shell common functions, cut

Source: Internet
Author: User

1. Description

Cut [Option] files

Cut-D 'separator '-F Fields

Retrieve some specific fields of the file with different fields

2. Options

-D: used to define the delimiter. The default Delimiter is the tab key, which is used with-f.

-F: The field to be retrieved. Separate the fields according to-D.

-C: Take the character (characters) as the single bit to retrieve the fixed metaspace; the value after-C specifies the number of characters to be output.

The-C and-F parameters can be described as follows:

N nth character or field

N-from the first character or field to the end of the file

N-M from N to M characters or fields

-M: From the first character to the MB character or field

3. Example

Echo $ PATH | cut-D:-F 3rd // fetch 5th rows and rows

Last | cut-D ''-F 1

Last | cut-C 9-15

Last | cut-C 9-

Last | cut-d ""-F 1 | sort | uniq

Last | cut-d ""-F 1 | sort | uniq-C

Reference

[1]Http://doc.linuxpk.com/425.html

[2]Http://linux.vbird.org/linux_basic/0320bash.php#split

Related Article

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.