[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 在 shell 中能对 ip 地址排序吗?



Dongsheng Song 写道:
谢谢,原来 “-k” 还能这样多次使用呢,长见识了。

2009/5/12 Alyex Ye <alyex.ye@gmail.com>:
正解
sort -n -t\. -k1,1 -k2,2 -k3,3 -k4,4 ip.txt

求助Google得来
http://www.madboa.com/geek/sort-addr/


$ sort --version-sort <<EOF
> 192.168.2.234
> 192.168.2.51
> 192.168.2.247
> 192.168.4.51
> 192.168.2.50
> 10.10.66.207
> 10.1.160.53
> EOF
10.1.160.53
10.10.66.207
192.168.2.50
192.168.2.51
192.168.2.234
192.168.2.247
192.168.4.51


Reply to: