Shell 字符串操作

Shell 字符串操作

赋值

astr="Hello World"
bstr=Hello

substring

echo $astr
echo ${astr:6}
echo ${astr:0:6}

replace

echo ${astr/s1/s2} # ReplaceFirst
echo ${astr//s1/s2} # ReplaceAll

contact

cstr="$astr+$bstr"
posted @ 2019-12-22 16:17  stdpain  阅读(179)  评论(0编辑  收藏  举报