shell 子串基础语法
${var} return the value of var
${#var} return the length of var
${var:offset} return the value from offsetto end in var
${var:offset:length} return the value of var with length starting from offset
${var#word} Removes the shortest word substring matching word from the beginning of var
${var##word} Removes the longest word substring matching word from the beginning of var
${var%word} Removes the shortest word substring matching word from the endding of var
${var%%word} Removes the longest word substring matching word from the endding of var
${var/word1/word2} Replace the first matched word1 in var with word2
${var//word1/word2} Replace all word1 in var with word2
## 扩展变量
${parameter:-word} if parameter is null, return word string
${parameter:=word} if parameter is null, replace parameter to word and return the value of word
${parameter:?word} If the parameter is null, the word string is output as standard error, otherwise the value of the var is output
${parameter:+word} if par is null, it do nothing, otherwise reture word