Follow

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

youtube.com/watch?v=IGe0GnlIWq

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
...

· · 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
3.183.14.16/32
3.233.163.76/32
...

Sign in to participate in the conversation
Octodon

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