This post is a two-parter. I'm trying to sort a set of ip statements that look like:
ifconfig em0 alias 172.16.80.1/28
ifconfig em0 alias 172.16.180.1/32
...
ifconfig em0 alias 172.16.1.1/32
by ip. Is it possible to return a range by using a regular expression? The following returns an error
%/172.*/sort n
and this doesn't (apparently) do anything:
g/172.*/sort n
Can this even be done?
Now, I solved the range problem directly:
18,31 sort
but this sorts in ASCII-order, not numerically (wrt the ips).
ifconfig em0 alias 172.16.180.1/32
...
ifconfig em0 alias 172.16.80.1/28
and unfortunately this Vim Tip tip doesn't work:
18,31 sort n
In fact, it does nothing; sorting on the original list leaves the original order intact. So even if returning a range via regular expressions is impossible, how do I sort these lines numerically?
UPDATE The following works:
18,31 !sort -n -t . -k 3,3 -k 4,4
(I only need to sort on the last two two bytes.)