文件名:silent_grep.sh
文件内容:
if [ $# -ne 2 ];
then
echo "$0 match_text filename"
fi
match_text=$1
filename=$2
grep -q $match_text $filename
if [ $? -eq 0 ];
then
echo "The text exists in the file"
else
echo "Text does not exist in the file"
fi
文件执行方式:
[root@zhangshibo temp]# ./silent_grep.sh hack data.txt
The text exists in the file
[root@zhangshibo temp]# ./silent_grep.sh zhangshibo data.txt
Text does not exist in the file
使用silent_grep.sh搜索文本
本文介绍了一个名为silent_grep.sh的脚本,用于在指定文件中搜索特定文本。脚本通过grep命令进行文本匹配,并输出文本存在或不存在的结果。
649

被折叠的 条评论
为什么被折叠?



