alphanumeric sort

2007/03/12

Naming schemes of the form “www01, www02” aren’t great. You’ll run out of space after 100 names anyway.

perl -e 'sub sorter { ($aw,$an)=$a=~/^(\w+)(\d+)$/;
($bw,$bn)=$b=~/^(\w+)(\d+)$/; return $aw cmp $bw || $an <=> $bn; }
print sort sorter <>;' < file

Comments