shell判断文件中是否包含字符串

# 判断hosts中有域名
if cat '/etc/hosts' | grep "$input_domain" > /dev/null
then
    echo "域名为$input_domain已存在"
    domain_flag=''
    continue
fi
原文地址:https://www.cnblogs.com/jiqing9006/p/13080975.html