I have a file that looks like this:
foo03a foo02b quux01a foo01a foo02a foo01b foo03b quux01b
I'd like it ordered by the last character (so
b appear together) and then by the preceding number, and then by the prefix (though this is not essential). So that it results in:
foo01a quux01a foo02a foo03a foo01b quux01b foo02b foo03b
It actually doesn't particularly matter where
quux01b appear, as long as they're in the relevant group -- they can appear as shown, before
foo01b, or after
Why? These are server names used in a blue/green deployment, so I want the 'A' servers together, then the 'B' servers.
I found the
-k switch to GNU sort, but I don't understand how to use it to specify a particular character, counting from the end of the string.
cat foos | rev | sort | rev, but that sorts
foo10b (when we count up that far) into the wrong place.