shell 字符串 开始 结束 子字符串

来源:互联网 发布:淘宝客服靠谱吗 编辑:程序博客网 时间:2024/06/16 06:04
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

原创粉丝点击