打印出在两个文件中都不存在元素
时间:2008-05-16 来源:jordanfang
#!/bin/sh
echo "下面为那些没有在联系人组里面的人" >/opt/tmp/check_person_notingroup.out
file="contacts.cfg contacts_level2.cfg contacts_level3.cfg contacts_level4.cfg contacts_level5.cfg contacts_level6.cfg"
for h in $file
do
for i in `find /usr/local/nagios/etc/ -type f -name $h |xargs -i cat {} | grep contact_name | awk '{print $2}'`
do
grep $i /usr/local/nagios/etc/contactgroups.cfg 2>/dev/null 1>/dev/null || grep $i /usr/local/nagios/etc/contactgroups_charge.cfg 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]
then
echo $i >>/opt/tmp/check_person_notingroup.out
fi
done
done
打印出在两个文件中都不存在元素
echo "下面为那些没有在联系人组里面的人" >/opt/tmp/check_person_notingroup.out
file="contacts.cfg contacts_level2.cfg contacts_level3.cfg contacts_level4.cfg contacts_level5.cfg contacts_level6.cfg"
for h in $file
do
for i in `find /usr/local/nagios/etc/ -type f -name $h |xargs -i cat {} | grep contact_name | awk '{print $2}'`
do
grep $i /usr/local/nagios/etc/contactgroups.cfg 2>/dev/null 1>/dev/null || grep $i /usr/local/nagios/etc/contactgroups_charge.cfg 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]
then
echo $i >>/opt/tmp/check_person_notingroup.out
fi
done
done
打印出在两个文件中都不存在元素
相关阅读 更多 +