2019-08-19 15:26:40 2893浏览
今天千锋扣丁学堂Linux培训老师给大家分享一篇关于Linux shell获得字符串所在行数及位置的方法,希望对同学们有所帮助,下面我们一起来看一下吧。
[root@root]# cat test apple bit create delect exe flow good [root@root]# cat test | grep -n exe 5:exe [root@root]# cat test | grep -n exe | awk -F ":" '{print $1}' 5
[root@root]# cat test apple bit create delect exe flow good [root@root]# [root@root]# sed -n '/exe/=' test 5
[root@root]# echo 'uellevcmpottcap' | awk -F 'ott' '{print $1}'; uellevcmp [root@root]# echo 'uellevcmpottcap' | awk -F 'ott' '{print $1}' | wc -c 10
[root@root]# str='uellevcmpottcap';str1='ott';awk 'BEGIN{print index("'${str}'","'${str1}'") }' 10
【关注微信公众号获取更多学习资料】 【扫码进入JavaEE/微服务VIP免费公开课】