当前位置: 技术问答>linux和unix
一段bash脚本
来源: 互联网 发布时间:2016-08-12
本文导语: 今天看脚本,遇到了这么一行,搜索引擎也不知道搜什么关键字,所以上来问问 log_stack=${log_stack#*:} 现行谢过了 | 删除变量log_stack中第一个":"左侧(含冒号)的字符 Shell Parameter Expansion: ${pa...
今天看脚本,遇到了这么一行,搜索引擎也不知道搜什么关键字,所以上来问问
log_stack=${log_stack#*:}
现行谢过了
log_stack=${log_stack#*:}
现行谢过了
|
删除变量log_stack中第一个":"左侧(含冒号)的字符
Shell Parameter Expansion:
${parameter#word}
${parameter##word}
The word is expanded to produce a pattern just as in filename expansion (see
Section 3.5.8 [Filename Expansion], page 22). If the pattern matches the beginning
of the expanded value of parameter, then the result of the expansion is
the expanded value of parameter with the shortest matching pattern (the ‘#’
case) or the longest matching pattern (the ‘##’ case) deleted. If parameter is ‘@’
or ‘*’, the pattern removal operation is applied to each positional parameter in
turn, and the expansion is the resultant list. If parameter is an array variable
subscripted with ‘@’ or ‘*’, the pattern removal operation is applied to each
member of the array in turn, and the expansion is the resultant list.
Shell Parameter Expansion:
${parameter#word}
${parameter##word}
The word is expanded to produce a pattern just as in filename expansion (see
Section 3.5.8 [Filename Expansion], page 22). If the pattern matches the beginning
of the expanded value of parameter, then the result of the expansion is
the expanded value of parameter with the shortest matching pattern (the ‘#’
case) or the longest matching pattern (the ‘##’ case) deleted. If parameter is ‘@’
or ‘*’, the pattern removal operation is applied to each positional parameter in
turn, and the expansion is the resultant list. If parameter is an array variable
subscripted with ‘@’ or ‘*’, the pattern removal operation is applied to each
member of the array in turn, and the expansion is the resultant list.