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