[root@iZ2zee01smz5y5cfifeox0Z shell]# cat ip.txt
192.168.1.20
[root@iZ2zee01smz5y5cfifeox0Z shell]# cat ip.txt | cut -d \. -f 3
1
[root@iZ2zee01smz5y5cfifeox0Z shell]# cat ip.txt | cut -d \. -f 2
192.168.1.20
[root@iZ2zee01smz5y5cfifeox0Z shell]# cat ip.txt | cut -d \. -f 3
1
[root@iZ2zee01smz5y5cfifeox0Z shell]# cat ip.txt | cut -d \. -f 2
168
这里主要是用了cut工具的-d和-f参数:
-d:指定字段的分隔符,默认的字段分隔符为“TAB”;
-f:显示指定字段的内容;