shell获取字符串的行号和位置01获取字符串的行号方法一:使用grep-n[root@root]#cattestapplebitcreateselectexeflowgood[root@根]#猫测试|grep-nexe5:exe[root@root]#猫测试|grep-n执行|awk-F":"'{print$1}'5方法二:使用sed-n'/querystring/='file[root@root]#cattestapplebitcreateselectexeflowgood[root@root]#[root@root]#sed-n'/exe/='test502获取字符在字符串中的位置方法一:使用awk-F和wc-ccombo[root@root]#echo'uellevcmpottcap'|awk-F'ott''{print$1}';uellevcmp[root@root]#echo'uellevcmpottcap'|awk-F'ott''{print$1}'}'|wc-c10方法二:使用awk'BEGIN{printindex("'${str}'","'${str1}'")}'[root@root]#str='uellevcmpottcap';str1='ott';awk'BEGIN{printindex("'${str}'","'${str1}'")}'10
