Classificação da versão do Linux; letras primeiro

0

O GNU sort -V é ótimo para classificar endereços IP. Infelizmente, ele lança todas as linhas com letras iniciais (em oposição a números) na parte inferior da pilha. Existe uma maneira de contornar isso?

Nota:
192.168.0.103 está faltando porque é o host local.
• Os endereços MACs / HW foram alterados.

• cat

user@host:~$ cat /proc/net/arp
IP address       HW type     Flags       HW address            Mask     Device
192.168.0.106    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.1      0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.101    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.104    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.110    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.108    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.107    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.102    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.105    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.100    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.109    0x1         0x2         00:00:00:00:00:00     *        wlan0

• classificar -V

user@host:~$ sort -V /proc/net/arp
192.168.0.1      0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.100    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.101    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.102    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.104    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.105    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.106    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.107    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.108    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.109    0x1         0x2         00:00:00:00:00:00     *        wlan0
192.168.0.110    0x1         0x2         00:00:00:00:00:00     *        wlan0
IP address       HW type     Flags       HW address            Mask     Device
por tjt263 02.10.2018 / 16:25

1 resposta

4

Aqui está uma técnica para manter o cabeçalho na parte superior: redirecionar o arquivo e, a partir do fluxo, consumir a primeira linha e, em seguida, dar o restante das linhas para classificar.

{ IFS= read -r header; echo "$header"; sort -V; } < /proc/net/arp
    
por 02.10.2018 / 16:32