<div dir="ltr">The recent thread on CIDR aggregation cleanup scripts reminds me that I'm looking for a similarly efficient implementation of a related tool. (I'm gearing up to write my own in Perl, but don't want to reinvent the wheel.)<div><br></div><div><div>I'd like a fast, Unix-pipeline-ready tool that *replaces* all IPs within that range with a supplied string, using a simple config file as input, and ideally with autodetection of IP-address "word" boundaries, as in:</div><div><br></div></div><div>$ cat cidr-replace.cfg</div><div><a href="http://105.170.75.0/24|[Unitel]">105.170.75.0/24|[Unitel]</a></div><div><a href="http://209.112.128.0/18|[ACS]">209.112.128.0/18|[ACS]</a><br></div><div><a href="http://209.165.128.0/18|[GCI]">209.165.128.0/18|[GCI]</a><br></div><div><a href="http://192.0.2.0/24|[TEST-NET-1]">192.0.2.0/24|[TEST-NET-1]</a></div><div><a href="http://198.51.100.0/24|[TEST-NET-2]">198.51.100.0/24|[TEST-NET-2]</a></div><div><a href="http://203.0.113.0/24|[TEST-NET-3]">203.0.113.0/24|[TEST-NET-3]</a><br></div><div><br></div><div>$ echo "source,data1,data2,209.112.130.2,data3" | cidr-replace cidr-replace.cfg</div><div>source,data1,data2,[ACS],data3<br></div><div><br></div><div><br></div><div>And I know this is kludgy, but it would also be useful for quick-and-dirty work if it had a flag to "append" the string using a known delimiter, as in:</div><div><br></div><div><div>$ echo "source,data1,data2,209.112.130.2,data3" | cidr-replace --append ',' cidr-replace.cfg</div><div>source,data1,data2,209.112.130.2,[ACS],data3<br></div><div></div></div><div><br></div><div>(But I'm happy to hack that last functionality into an existing script.)</div><div><br></div><div></div><div>-- <br></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Royce</div></div></div></div></div>