码迷,mamicode.com
首页 > 系统相关 > 详细

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

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

标签:class   style   The   test   pre   awk   span   输出   color   

 

#!/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 查找字符串中字符出现的位置

标签:class   style   The   test   pre   awk   span   输出   color   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!