Linux Basic Command--cut

Source: Internet
Author: User

Cut (option) (parameter) cut is a tool for working with text that can be used to remove specific fields.
When selecting a field "1,3" represents the 1th and 3rd, "1-3" represents the first to the third, "3" stands from the beginning to the third, "3-" represents from the third to the last

The first 10 behaviors in/etc/passwd

1[Email protected] admin]#Head-Ten/etc/passwd>a2[Email protected] admin]#Cata3ROOT:X:0:0: root:/root:/bin/Bash4BIN:X:1:1: bin:/bin:/sbin/Nologin5DAEMON:X:2:2:d aemon:/sbin:/sbin/Nologin6ADM:X:3:4: adm:/var/adm:/sbin/Nologin7 LP: x:4:7:LP:/var/spool/lpd:/sbin/Nologin8 Sync: x:5:0:Sync:/sbin:/bin/Sync9SHUTDOWN:X:6:0: shutdown:/sbin:/sbin/shutdownTenHALT:X:7:0: halt:/sbin:/sbin/Halt OneMAIL:X:8: A: mail:/var/spool/mail:/sbin/Nologin AUUCP:X:Ten: -: Uucp:/var/spool/uucp:/sbin/nologin

-C Number: Displays the characters of the first few columns

1[Email protected] admin]#Cut-C1-5,7a2 Root::3 bin:x14 Daemo:5 adm:x36 LP: x::7 Sync::8 SHUTDW9 Halt::Ten Mail:: OneUUCP::

-D: Specifies the delimiter for the field, the Default field delimiter is tab, and the-f option is required;

-F: Displays the contents of the specified section

1[Email protected] admin]#Cut-D:-F1 a2 Root3 bin4 Daemon5 ADM6 LP7 Sync8 shutdown9 HaltTen Mail One UUCP A separated by a colon, showing the first segment being truncated -[Email protected] admin]#Cut-D:-F3 a - 0 the 1 - 2 - 3 - 4 + 5 - 6 + 7 A 8 at Ten - separated by a colon, showing the third paragraph that was truncated -[Email protected] admin]#Cut-D:-f1,2,6-a -root:x:/root:/bin/Bash -bin:x:/bin:/sbin/Nologin -daemon:x:/sbin:/sbin/Nologin inadm:x:/var/adm:/sbin/Nologin - LP: x:/var/spool/lpd:/sbin/Nologin to Sync: x:/sbin:/bin/Sync +shutdown:x:/sbin:/sbin/shutdown -halt:x:/sbin:/sbin/Halt themail:x:/var/spool/mail:/sbin/Nologin *uucp:x:/var/spool/uucp:/sbin/Nologin $Separated by a colon, displays the second and sixth paragraphs of the first paragraph that were truncated to all after, but he also shows the separator character. I think it's easy to tell.

--complement: Reverse Selection

1[Email protected] admin]#Cut-D:-f1,2,6-  --complement a2 0:0: Root3 1:1: Bin4 2:2:d Aemon5 3:4: ADM6 4:7:LP7 5:0:Sync8 6:0: Shutdown9 7:0: HaltTen 8: A: Mail One Ten: -: UUCP

Linux Basic Command--cut

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.