Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 656 Bytes

File metadata and controls

21 lines (17 loc) · 656 Bytes
aliases author date tags title
/2011/01/06/using-gnu-sort-to-sort-a-list-by-ip-address/
Major Hayden
2011-01-06 05:52:58 -0800
command line
linux
sysadmin
Using GNU sort to sort a list by IP address

My daily work requires me to work with a lot of customer data and much of it involves IP address allocations. If you find that you need to sort a list by IP address with GNU sort on a Linux server, just use these handy arguments for sort:

sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 somefile.txt

For this to work, the file you're sorting needs to have the IP address as the first item on each line.