场景:判断字符abcde是否含有字符abc
[[ "abcde" =~ "abc" ]] && echo "this is true" || echo "this is not true"
if [[ "abcde" =~ "abc" ]]; then
echo "this is true"
else
echo "this is not true"; exit
fi
[[ "abcde" =~ "abc" ]] && echo "this is true" || echo "this is not true"
if [[ "abcde" =~ "abc" ]]; then
echo "this is true"
else
echo "this is not true"; exit
fi