shell中的字符串操作——字符串的切割
生活随笔
收集整理的這篇文章主要介紹了
shell中的字符串操作——字符串的切割
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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-
let index=index+
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
總結(jié)
以上是生活随笔為你收集整理的shell中的字符串操作——字符串的切割的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springboot 中如何正确在异步线
- 下一篇: html中的字幕滚动marquee属性