Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ${string##substring}
- Strips longest match of $substring from front of $string.
- 1 stringZ=abcABC123ABCabc
- 2 # |----|
- 3 # |----------|
- 4
- 5 echo ${stringZ#a*C} # 123ABCabc
- 6 # Strip out shortest match between 'a' and 'C'.
- 7
- 8 echo ${stringZ##a*C} # abc
- 9 # Strip out longest match between 'a' and 'C'.
- ${string%substring}
- Strips shortest match of $substring from back of $string.
- ${string%%substring}
- Strips longest match of $substring from back of $string.
- 1 stringZ=abcABC123ABCabc
- 2 # ||
- 3 # |------------|
- 4
- 5 echo ${stringZ%b*c} # abcABC123ABCa
- 6 # Strip out shortest match between 'b' and 'c', from back of $stringZ.
- 7
- 8 echo ${stringZ%%b*c} # a
- 9 # Strip out longest match between 'b' and 'c', from back of $stringZ.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement