shell
陈大豆
这个作者很懒,什么都没留下…
展开
-
shell中>和>>和<和<<的区别
https://www.jianshu.com/p/70136d731ca0转载 2020-09-20 22:14:21 · 4389 阅读 · 1 评论 -
Shell脚本中判断字符串是否被包含在内,判断文件或者文件夹是否存在
1、字段 grep:案例: str1="abcdefgh"str2="def"result=$(echo $str1 | grep "${str2}")if [[ "$result" != "" ]];then echo "包含"else echo "不包含"fi2. 字符串运算符 =~:案例:str1="abcdefgh"str2="def"if [[ $str1 =~ $str2 ]];then echo "包含"else echo "不包含"原创 2020-09-20 21:53:37 · 3836 阅读 · 0 评论