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

shell中的字符串操作——字符串的切割

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

标签:字符   code   ref   cheng   cat   tps   htm   操作   yaml   

 

default.yaml

{default_baseurl: http://10.113.10.68:8082}

test.sh

a=`cat default.yaml`
t=":"
index=`awk -v a="$a" -v b=":" BEGIN{print index(a,b)}`
diff=${#a}-$index-2
let index=index+1
default_url=`echo ${a:$index:$diff}|sed $s/\‘//g`
echo $default_url

输出

bogon:conf macname$ ./test.sh 
http://10.113.10.68:8082

 

 

参考:

https://www.cnblogs.com/chengmo/archive/2010/10/02/1841355.html

 

shell中的字符串操作——字符串的切割

标签:字符   code   ref   cheng   cat   tps   htm   操作   yaml   

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

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