Linux shell脚本 回显中寻找指定字符串

我运行一个脚本,想查看该脚本回显是否包含指定字符串,同时要求回显内容全部输出在屏幕。
我现在是用tee 将回显写入文件,然后cat grep特定字符串,再判断状态$?。
想问问有没有不用写入文件的操作。

参考一下: linux shell 字符串查找_whatday的专栏-CSDN博客_shell 字符串查找 方法一:利用grep查找strA="long string"strB="string"result=$(echo $strA | grep "${strB}")if [[ "$result" != "" ]]then echo "包含"else echo "不包含"fi先打印长字符串,然后在长字符串中 grep 查找要搜索的字符串,用变量result记录结... https://blog.csdn.net/whatday/article/details/105466652