Tee-hee! Thanks to Walt for his annual reminder how awesome one-liners are!

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

· · Web · 0 · 0 · 1

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

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!