shell 判断字符串中是否含有指定字符

如题所述

第1个回答  2016-12-10
比如变量是str str="this is a string" 要想在判断str中是否含有"this"这个字符串,下面的语句是可行的 [[ $str =~ "this" ]] && echo "\$str contains this" [[ $str =~ "that" ]] || echo "\$str does NOT contain this" 其实这里就是用到了"[...本回答被提问者采纳
相似回答