分页: 1 / 1

请教shell排序问题

发表于 : 2011-08-25 17:38
215317196
arp -n 输出很多IP,如下:

代码: 全选

192.168.0.178            ether   00:1E:6F:00:25:24   C                     eth0
192.168.0.179            ether   00:1E:6E:00:15:82   C                     eth0
192.168.0.53             ether   6C:F0:49:88:3E:CA   C                     eth0
192.168.0.47             ether   00:27:19:9C:68:34   C                     eth0
192.168.2.184            ether   00:1E:6E:00:58:39   C                     eth0
192.168.1.1            ether   00:0A:EB:09:8B:F4   C                     eth0
192.168.1.111            ether   1C:6F:65:9C:B4:C6   C                     eth0
192.168.3.183            ether   00:1E:6E:00:58:2B   C                     eth0
192.168.3.2            ether   00:1E:6E:00:58:2F   C                     eth0
192.168.2.183            ether   00:1E:6E:00:58:2B   C                     eth0
192.168.3.13            ether   00:1E:6E:00:5F:2B   C                     eth0

我想要按IP排序,怎么做啊。!!!

Re: 请教shell排序问题

发表于 : 2011-08-25 18:23
fnan
直接sort就是了。

Re: 请教shell排序问题

发表于 : 2011-08-25 20:21
1qa2ws3ed

代码: 全选

sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 arp-output-file

Re: 请教shell排序问题

发表于 : 2011-08-26 12:46
215317196
以经解决了,谢谢!采纳3楼!!

代码: 全选

sort -n -u -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4