$ {parameter/pattern/string}
模式替换.就像路径名扩展一样,扩展模式以产生模式.扩展参数,并将模式与其值的最长匹配项替换为字符串.如果pattern以/
开头,则pattern的所有匹配项都将替换为字符串.通常只替换第一个比赛.如果pattern以#
开头,则它必须与参数的扩展值的开头匹配.如果模式以%
开头,则它必须在参数的扩展值的末尾匹配.如果string为null,则将删除模式的匹配项,并且可以省略以下/
模式.如果参数是 @
或 *
,则将替换操作依次应用于每个位置参数,并且扩展名是结果列表.如果parameter是一个用 @
或 *
下标的数组变量,则将替换操作依次应用于该数组的每个成员,并且扩展为结果列表.>
Pattern substitution. The pattern is expanded to produce a pattern just as in pathname expansion. Parameter is expanded and the longest match of pattern against its value is replaced with string. If pattern begins with /
, all matches of pattern are replaced with string. Normally only the first match is replaced. If pattern begins with #
, it must match at the beginning of the expanded value of parameter. If pattern begins with %
, it must match at the end of the expanded value of parameter. If string is null, matches of pattern are deleted and the /
following pattern may be omitted. If parameter is @
or *
, the substitution 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 substitution operation is applied to each member of the array in turn, and the expansion is the resultant list.
也就是说,将 $ {something//,/}
扩展为 $ something
,并删除所有出现的
.
That is, ${something//,/}
is expanded to the $something
with all the occurrences of ,
removed.
这篇关于Bash参数扩展中的"//"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!