cut 选项 文件名
-f 列号 提取第几列
-d 分隔符 指定分隔符把行分成多列
[[email protected] ~]# cat testfile no. name sex score 1 zhangsan m 88 2 lisi f 89 3 wangwu m 87 [[email protected] ~]# cut -f 2 testfile 注释:默认分隔符是制表符\t name zhangsan lisi wangwu [[email protected] ~]# cut -f 2,4 testfile name score zhangsan 88 lisi 89 wangwu 87
[[email protected] ~]# cat testfile no. na:me sex sco:re 1 zhang:san m 8:8 2 li:si f 8:9 3 wang:wu m 8:7 [[email protected] ~]# cut -f 1,3 -d : testfile no. na:re 1 zhang:8 2 li:9 3 wang:7
[email protected] ~]# cut -f 1 -d : /etc/passwd|grep xiong xiongjiawei [[email protected] ~]# grep xiong /etc/passwd|cut -d : -f 1 xiongjiawei [[email protected] ~]# grep xiong /etc/passwd|cut -d ":" -f 1 xiongjiawei [[email protected] ~]# grep xiong /etc/passwd|cut -f 1 -d : xiongjiawei [[email protected] ~]# grep xiong /etc/passwd|cut -f 1 -d ":" xiongjiawei
时间: 2024-11-12 15:53:55