Alternative form of long prefix/suffix removal (#1941)
The ${foo/%from} is an alternative form of the long suffix removal. Likewise, he ${foo/#from} is an alternative form of the long prefix removal. Test cases: ~~~bash foo=gododa # The following are the same: Long prefix removal. # Result: r=a r=${foo/#g*d} r=${foo##g*d} # (Compare to short prefix removal) # Result: r=oda r=${foo#g*d} foo=agogod # The following are the same: Long suffix removal. # Result: r=a r=${foo/%g*d} r=${foo%%g*d} # (Compare to short suffix removal) # Result: r=ago r=${foo%g*d} ~~~
This commit is contained in:
parent
5efbf15d4f
commit
b91885ec71
2
bash.md
2
bash.md
|
@ -187,7 +187,9 @@ dir=${src%$base} #=> "/path/to/" (dirpath)
|
|||
| `${foo#prefix}` | Remove prefix |
|
||||
| --- | --- |
|
||||
| `${foo%%suffix}` | Remove long suffix |
|
||||
| `${foo/%suffix}` | Remove long suffix |
|
||||
| `${foo##prefix}` | Remove long prefix |
|
||||
| `${foo/#prefix}` | Remove long prefix |
|
||||
| --- | --- |
|
||||
| `${foo/from/to}` | Replace first match |
|
||||
| `${foo//from/to}` | Replace all |
|
||||
|
|
Loading…
Reference in New Issue