Folks,
Not got much scritping experience, so I expect this will be a fairly trivial fix for those that know what they're doing...
I've got two files:
root[my-box]# cat /tmp/exemption_list
# This file will contain comments
# and blank lines.
aaa.bbb.ccc.000
aaa.bbb.ccc.222
aaa.bbb.ccc.444
aaa.bbb.ccc.666
root[my-box]#
root[my-box]# cat /tmp/subnet_list
aaa.bbb.ccc.000
aaa.bbb.ccc.111
aaa.bbb.ccc.222
aaa.bbb.ccc.333
aaa.bbb.ccc.444
aaa.bbb.ccc.555
aaa.bbb.ccc.666
aaa.bbb.ccc.777
aaa.bbb.ccc.888
aaa.bbb.ccc.999
root[my-box]#
What I'm trying to do, is run through the subnet_list and pick out and remove all of the matching addresses that exist in the exemption list and then write the amended list back to subnet_list - so essentially I'll end up with a list of subnets minus the exempt ones. Exemption list is something that will be ever changing, as a result I can't hard code it into the script.
The closest I've been able to get is:
root[my-box]# egrep -v "#|^$" /tmp/exemption_list| while read line; do grep -v $line /tmp/subnet_list >> /tmp/subnet_list_result; done
root[my-box]# mv /tmp/subnet_list_result /tmp/subnet_list
Which isn't quite right at all...
Can anyone help tweak the egrep command so I end up with a subnet_list file containing no exempt addresses and no duplicates?
Thanks in advance.
CiCa