Tee-hee! Thanks to Walt for his annual reminder how awesome #perl one-liners are! #tpc2017dc
https://www.youtube.com/watch?v=IGe0GnlIWq4
My use today (squash HUGE IP list into CIDR blocks):
perl -MNet::CIDR::Lite -ne 'BEGIN{$cidr = Net::CIDR::Lite->new} s/[\r\n]+$//; $cidr->add_ip($_); END{print join "\r\n", $cidr->list; print "\r\n"}' IPs.txt
3.183.14.16/32
3.233.163.76/32
...
Cleaner if Unix (or using -l):
perl -MNet::CIDR::Lite -lnE 'BEGIN{$cidr = Net::CIDR::Lite->new} $cidr->add_ip($_); END{say join "\n", $cidr->list}' IP.txt | head
3.183.14.16/32
3.233.163.76/32
...