Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.93 KB | None | 0 0
  1. ${string##substring}
  2.  
  3.     Strips longest match of $substring from front of $string.
  4.  
  5.        1 stringZ=abcABC123ABCabc
  6.        2 #       |----|
  7.        3 #       |----------|
  8.        4
  9.        5 echo ${stringZ#a*C}      # 123ABCabc
  10.        6 # Strip out shortest match between 'a' and 'C'.
  11.        7
  12.        8 echo ${stringZ##a*C}     # abc
  13.        9 # Strip out longest match between 'a' and 'C'.
  14.  
  15. ${string%substring}
  16.  
  17.     Strips shortest match of $substring from back of $string.
  18. ${string%%substring}
  19.  
  20.     Strips longest match of $substring from back of $string.
  21.  
  22.        1 stringZ=abcABC123ABCabc
  23.        2 #                    ||
  24.        3 #        |------------|
  25.        4
  26.        5 echo ${stringZ%b*c}      # abcABC123ABCa
  27.        6 # Strip out shortest match between 'b' and 'c', from back of $stringZ.
  28.        7
  29.        8 echo ${stringZ%%b*c}     # a
  30.        9 # Strip out longest match between 'b' and 'c', from back of $stringZ.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement