The shell string operations - cutting the string

 

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

Export

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

 

 

reference:

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

 

Guess you like

Origin www.cnblogs.com/sea-stream/p/11403153.html