首页 > 系统服务 > 详细

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

时间:2019-08-24 00:58:11      阅读:764      评论:0      收藏:0      [点我收藏+]

 

#!/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

 

 

参考:

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!