Sort using rDNS naming
Notice
This post has nothing to do with dns or reverse dns. This is only talking about sorting text.
Main
Sort of like how flippin' freedesktop.org uses "reverse DNS names" to get such lovely files as /usr/share/applications/org.geeqie.Geeqie.desktop
, I wanted to sort some domain names. A sorted list looks less like I just made it up, and like I pulled it out of a report or tool!
So I have a small script here that sorts via "reverse DNS" convention.
awk -F'.' ' { for (i=NF; i>0; i--) { printf "%s %s", $(i), (i>1 ? "." : "") } print $0 }' | sort | awk '{print $NF}'
It was too small to bother putting it in the files/ for this post.
Comments