+ -
当前位置:首页 → 问答吧 → 初学者写脚本,高手指点下啊!!!

初学者写脚本,高手指点下啊!!!

时间:2011-08-25

来源:互联网

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排序,怎么做啊。!!!

作者: 215317196   发布时间: 2011-08-25

直接sort就是了。

作者: fnan   发布时间: 2011-08-25

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

作者: 1qa2ws3ed   发布时间: 2011-08-25

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排序,怎么做啊。!!!

作者: 215317196   发布时间: 2011-08-25

直接sort就是了。

作者: fnan   发布时间: 2011-08-25

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

作者: 1qa2ws3ed   发布时间: 2011-08-25