我正在尝试检查域是否在服务器上处于事件状态。到目前为止,我得到了错误。
list=/root/domainlist.txt
for i in $(cat $list)
do
echo "checking " $i
$ip = host $i |grep -o -m 100 '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'
if [[ $ip == "xx.xx.xx.xx" ]]; then
$i >> /root/activedomains.txt
fi
done
输出:
activedomains: line 4: =: command not found
这是我得到的当前错误。
最佳答案
=
前后没有空格
- 作业中没有美元符号
您可能需要命令的结果,因此将其包含在
中$(
)
ip=$(host $i |grep -o -m 100 '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')
像这样写入文件
echo "$i" >> /root/activedomains.txt
关于linux - 检查域是否在服务器上处于事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15142343/