Bash: Find position of character in a string under OS X
问题 Is there any way to find a position of a first character within a string in Bash under Mac OS X ? Something like: stringZ=abcABC123ABCabc # 6 echo `expr index "$stringZ" C12` # C position. as desribed in Advanced Bash-Scripting Guide Couple of gotchas: The official index function expr index $string $substring is not present in OS X (BSD) match Installing gnu match ( gmatch ) does not seem to be a portable solution in the realm of BSD systems Any ideas? 回答1: This is a horrible hack, and may