1、字段 grep:
案例:
str1="abcdefgh"
str2="def"
result=$(echo $str1 | grep "${str2}")
if [[ "$result" != "" ]];then
echo "包含"
Shell脚本中判断字符串是否被包含在内,判断文件或者文件夹是否存在
最新推荐文章于 2024-07-03 11:18:24 发布
1、字段 grep:
案例:
str1="abcdefgh"
str2="def"
result=$(echo $str1 | grep "${str2}")
if [[ "$result" != "" ]];then
echo "包含"