strIsSubstring() { case"$2" in $1*) echo $2 is start by current str $1;; *$1) echo $2 is end by current str $1;; *$1*) echo $1 is substring of $2;; esac } strIsSubstring "b""abc"; strIsSubstring "c""abc"; strIsSubstring "a""abc";
运行结果:
b is substring of abc abc is end by current str c abc is start by current str a