linux shell脚本, #参数替换怎么理解?比如下面这个 echo ${PATH#*:} 这

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命令

追问

哦哦 谢谢大神

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网