![]() |
1
2
你的猜测是正确的。从
${parameter#word} ${parameter##word} 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 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. |
![]() |
2
1
是的,第二个版本使用bash扩展来剪切与*/regexp匹配的最长前缀$0,所以如果$0是“/bin/bash”,那么$0__*/将是“bash”。您可以使用'basename$0'来获得相同的结果。 |
![]() |
Plankt0n · Shell,执行一个需要逐一遍历多个值的命令 5 月前 |
![]() |
Fin · 如何使用bash从表中提取数据 5 月前 |
![]() |
aenagy · Bash声明不喜欢带空格的值 5 月前 |
![]() |
PkDrew · AND运算符“&”在“&tee”中的作用是什么? 5 月前 |
![]() |
elbarna · 正则表达式仅排除小写字符串,但保存包含大写的字符串 6 月前 |
![]() |
Harry · 使用“$!”获取后台作业的pid 6 月前 |
![]() |
nmr · 使用来自另一个shell脚本的if语句的返回码函数 6 月前 |
![]() |
minseong · Git sed忽略二进制文件 9 月前 |
![]() |
Jesper.Lindberg · 检查参数是否包含null 9 月前 |