2019-08-19 15:26:40 4047瀏覽
今天千鋒扣丁學(xué)堂Linux培訓(xùn)老師給大家分享一篇關(guān)于Linux shell獲得字符串所在行數(shù)及位置的方法,希望對同學(xué)們有所幫助,下面我們一起來看一下吧。
[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
【關(guān)注微信公眾號獲取更多學(xué)習(xí)資料】 【掃碼進(jìn)入JavaEE/微服務(wù)VIP免費(fèi)公開課】
查看更多關(guān)于“Linux培訓(xùn)資訊”的相關(guān)文章>>