###%%%%%%%%%%脚本的用法:
##准备测试文件:
[root@zabbix-agent opt]# while read line ;do echo ${line%% *};done < stu.txt
01 oldboy 18
02 lidao 17
03 baojewery 66
04 happyday 9
05 oldcao 99
##获取文件中的序号::::%从右边向左边删除:
[root@zabbix-agent opt]# while read line ;do echo ${line%% *};done < stu.txt
01
02
03
04
05
[root@zabbix-agent opt]# while read line ;
> do
> echo ${line%% *} ###########直到删除右边的空格为止
> done < stu.txt
01
02
03
04
05
#######“#”特殊符号从左向右删除::::
[root@zabbix-agent opt]# while read line; do echo ${line##*x}; done < stu.txt
18
17
66
9
99
[root@zabbix-agent opt]#
[root@zabbix-agent opt]#
[root@zabbix-agent opt]#
[root@zabbix-agent opt]#
[root@zabbix-agent opt]#
[root@zabbix-agent opt]# while read line; do echo ${line##x}; done < stu.txt^C
[root@zabbix-agent opt]# cat stu.txt
01 oldboyx18
02 lidaox17
03 baojeweryx66
04 happydayx9
05 oldcaox99