shell 查找字符串中字符出现的位置

时间:2019-08-24 00:58:11   收藏:0   阅读:764

 

#!/bin/bash
a="The cat sat on the mat"
test="cat"
awk -v a="$a" -v b="$test" BEGIN{print index(a,b)}

输出

bogon:Desktop macname$ ./test.sh 
5

 

 

参考:

 

原文:https://www.cnblogs.com/sea-stream/p/11403014.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!