cat /tmp/ips.txt | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n
10.0.0.2
10.0.0.5
10.0.0.20
192.168.0.2
192.168.0.4
192.168.0.12
sort ip addresses bash
Leave a reply
cat /tmp/ips.txt | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n
10.0.0.2
10.0.0.5
10.0.0.20
192.168.0.2
192.168.0.4
192.168.0.12