不废话直接上代码 str1="start tomcat ERROR,Please check and again!" str2="ERROR" if [[ $str1 =~ $str2 ]] then echo "包含ERROR" else echo "不包含ERROR" fi