I have various bash scripts that run, they scan log files for folks who try and make mischief, spam us and so on.
I have been struggling with this for some days trying to figure this out.
I have a text file with a list of with ip's
I use sed to scan the list and remove ip's such as our ip and other known ips and ip ranges. That get added to this list from people who perhaps make a mistake.
In the fist line I am trying to match all
and any ip beginning with 45.
Ideally I would like remove the following
22.214.171.124/8 and or any of the net masks up to
sed -i '' '/^45.*.*.*/d' /directory/blocked_subnets/somelist sed -i '' '/^50.81.238.*/d' /directory/blocked_subnets/somelist sed -i '' '/^50.84..*/d' /directory/blocked_subnets/somelist
These lines do work bit sometimes not as intended.
I have tried various regex's I have found on the net but they don't seem to work.
I was hoping someone who more experience in this can help me refine this sed -i to work properly.
The '' are because I am doing this on a freebsd machine.
Thank you in advance.