Take the tour ×  This post is a two-parter. I'm trying to sort a
set of ip statements that look like:  ifconfig em0 alias
ifconfig em0 alias ifconfig em0 alias  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 ifconfig em0 alias  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.)  share|improve this question add comment  1
Answer  up vote 2 down vote accepted  You can specify a regex
for the beginning line