I'm a sysadmin intern for a web hosting company and I'm trying to figure out how to get this task accomplished so I'll be as descriptive as possible.We have /etc/blockedips and /etc/donotblockI want to create a script that I can eventually setup in cron that will run like once every hour that scans both files and compares them and either a) send an alert out (we use watchdog) or b) automatically removes the IP inside /blockedips that matches what it shouldnt be blocking inside /donotblock as we have a lot of other techs who always add IPs that shouldnt be blocked.The problem I'm having as I am new to scripting is that I can easily run a simple grep command for straight IP addresses (ie: 76.76.76.76 will easily match across both files) but I cant figure out how to do the following:Lets say our companies IP block is 99.10.10.0/24. I don't want to put in every single address inside /donotblock, I just want the script to match any IP that is 99.10.10.* and I am drawing a blank on how to accomplish this.Can someone point me in the right direction with this?Edit: SampleSo the files look like so:/etc/donotblockUs26.225.128.0/18 43.150.128.0/20 44.50.142.0/2473.16.32.0/20 Everyone Else184.123.20.10184.123.20.11and then /etc/blocked_ips76.45.23.1lets say some tech added into the /blocked_ips73.16.32.10, I just want the script to look for 73.16.32.* to make up for that whole subnet.Speaking to the lead engineer he prefers to just have the script automatically remove the IP inside blocked_ips that match whats in donotblockThanks
How to scan and compare two files that will match IP addresses? Script for web hosting company
linux