[root@localhost demo]# cat alex.txt my name is alex.he love linux.he like eat apple. [root@localhost demo]# cut -c 4 alex.txt #截取每行的第4个字符 nll[root@localhost demo]# cut -c 4-7 alex.txt #截取每行的4到7个字符 namelovelike[root@localhost demo]# cut -c 4,6 alex.txt #截取每行的4和6的字符 nmlvlk [root@localhost demo]# cut -c -7 alex.txt #截取每行的第1个字符到第7个字符结束 my namehe lovehe like [root@localhost demo]# cut -c 9- alex.txt #截取每行的第9个字符到结尾 is alex.linux.eat apple.[root@localhost demo]# cat password root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:998:User for polkitd:/:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin abrt:x:173:173::/etc/abrt:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin [root@localhost demo]# cut -d ":" -f 7 password #指定分隔符号,进行截取第7个区域的内容 /bin/bash /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /bin/sync /sbin/shutdown /sbin/halt /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin /sbin/nologin [root@localhost demo]# cut -d ":" -f 1 password #指定分隔符,进行截取第1个区域的内容 root bin daemon adm lp sync shutdown halt mail operator games ftp nobody systemd-network dbus polkitd tss abrt sshd postfix [root@localhost demo]# cut -d ":" -f 1-3 password #指定分隔符,进行截取第一个区域到第三个区域的内容 root:x:0 bin:x:1 daemon:x:2 adm:x:3 lp:x:4 sync:x:5 shutdown:x:6 halt:x:7 mail:x:8 operator:x:11 games:x:12 ftp:x:14 nobody:x:99 systemd-network:x:192 dbus:x:81 polkitd:x:999 tss:x:59 abrt:x:173 sshd:x:74 postfix:x:89 [root@localhost demo]# cut -d ":" -f 1- password #读取所有 root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin adm:x:3:4:adm:/var/adm:/sbin/nologin lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin sync:x:5:0:sync:/sbin:/bin/sync shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin dbus:x:81:81:System message bus:/:/sbin/nologin polkitd:x:999:998:User for polkitd:/:/sbin/nologin tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin abrt:x:173:173::/etc/abrt:/sbin/nologin sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin [root@localhost demo]# cut -d ":" -f 5- password #指定分隔符,读取第5个区域到结尾 root:/root:/bin/bash bin:/bin:/sbin/nologin daemon:/sbin:/sbin/nologin adm:/var/adm:/sbin/nologin lp:/var/spool/lpd:/sbin/nologin sync:/sbin:/bin/sync shutdown:/sbin:/sbin/shutdown halt:/sbin:/sbin/halt mail:/var/spool/mail:/sbin/nologin operator:/root:/sbin/nologin games:/usr/games:/sbin/nologin FTP User:/var/ftp:/sbin/nologin Nobody:/:/sbin/nologin systemd Network Management:/:/sbin/nologin System message bus:/:/sbin/nologin User for polkitd:/:/sbin/nologin Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin :/etc/abrt:/sbin/nologin Privilege-separated SSH:/var/empty/sshd:/sbin/nologin :/var/spool/postfix:/sbin/nologin