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

# 判断hosts中有域名
if cat '/etc/hosts' | grep "$input_domain" > /dev/null
then
    echo "域名为$input_domain已存在"
    domain_flag=''
    continue
fi
posted @ 2020-06-09 21:33  TBHacker  阅读(7200)  评论(0编辑  收藏  举报