linux shell脚本, #参数替换怎么理解?比如下面这个
echo ${PATH#*:} 这是怎么替换的
运行结果如下 ,下面是直接echo $PATH的结果 ,PATH#*: <上面的> 比下面的多了一个环境产量 为什么?
图片看不清楚。
PATH#*: 是指从变量PATH中删除:前面的所有字符
从我这个可以看出差别就是第一个:前面的被干掉了。
这个是我在linux上 man bash 查到的:
${parameter#word}
${parameter##word}
Remove matching prefix pattern. The word is expanded to produce a pattern just as in pathname expansion. If the pattern matches the
beginning of the value of parameter, then the result of the expansion is the expanded value of parameter with the shortest matching pat-
tern (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.
追问man bash是什么 在哪查啊 是不是相当于VC的MSDN?
追答man 是linux下面shell命令
追问哦哦 谢谢大神