cut
Linux cut命令用于显示每行从开头算起 num1 到 num2 的文字。
 cut 命令从文件的每一行剪切字节、字符和字段并将这些字节、字符和字段写至标准输出。
 如果不指定 File 参数,cut 命令将读取标准输入。必须指定 -b、-c 或 -f 标志之一。
 语法
 cut  [-bn] [file]
 cut [-c] [file]
 cut [-df] [file]
-b, --bytes=LIST
               select only these bytes
-c, --characters=LIST
        select only these characters
-d, --delimiter=DELIM
        use DELIM instead of TAB for field delimiter
-f, --fields=LIST
        select  only these fields;  also print any line that contains no delimiter character, unless the -s option is
        specified
 -n     with -b: don't split multibyte characters
举例
 以这个文件做测试
echo 星期{一,二,三,四,五,六,天} |sed s#" "#\\n#g >> cut_nd.txt
[root@Labatt shell]# cat cut_nd.txt 
星期一cf
星期二af
星期三cf
星期四cf
星期五df
星期六cf
星期天cf
a35235qe
f34f352q
g564wqrq
3436yqwr 1)b 了解1-3,-3,-3,1,3用法
  
 
[root@Labatt shell]# cut -b 1-3 cut_nd.txt 
星
星
星
星
星
星
星
a35
f34
g56
343
[root@Labatt shell]# cut -b 1,5 cut_nd.txt 
�
�
�
�
�
�
�
a3
f3
gw
3y
[root@Labatt shell]# cut -b -3 cut_nd.txt 
星
星
星
星
星
星
星
a35
f34
g56
343
[root@Labatt shell]# cut -b 3- cut_nd.txt 
�期一cf
�期二af
�期三cf
�期四cf
�期五df
�期六cf
�期天cf
5235qe
4f352q
64wqrq
36yqwr2) nb
[root@Labatt shell]# cut -nb 1-3 cut_nd.txt 
星期一
星期二
星期三
星期四
星期五
星期六
星期天
a35
f34
g56
3433) c
[root@Labatt shell]# cut -c 1-3 cut_nd.txt 
星期一
星期二
星期三
星期四
星期五
星期六
星期天
a35
f34
g56
3434) d
[root@Labatt shell]# cat /etc/passwd | tail -n 3 
 cat:x:1002:1002::/home/cat:/bin/bash
 monkey:x:1003:1003::/home/monkey:/bin/bash
 tiger:x:1004:1004::/home/tiger:/bin/bash
 [root@Labatt shell]# cat /etc/passwd | tail -n 3 | cut -d : -f 1
 cat
 monkey
 tiger 










