I don't recommend the following over Don's suggestion. My approach is less efficient and less maintainable. I offer it only for your amusement, as my attempt at a shortest solution which restricts itself to POSIX-standard utilities.
Note: The pair of double-quotes after $1 shouldn't be necessary, but the oooold mawk that I was testing with wouldn't treat $1 as a string (which current POSIX rules require in that context).
If anyone can conjure something shorter, I'd love to see it.
Nope. Your suggestion is actually longer. It may be more efficient without the extra process in the pipeline, but it uses more characters.
Nice try, pamu, but yours is even a bit longer than elixir's. Also, your suggestion does not output a valid text file (it's missing the final newline).
Removing unnecessary whitespace and using filename "f":
While I've not removed it, I believe there is no need to use sort's -n option. Unless there exists a locale in which the digits do not sort from 0 to 9 -- if such a locale exists, I would truly appreciate being made of aware of it -- if the numbers are the same length, lexicographical and numerical sorting will yield identical results.
In section 5.2.1 of the C Standard titled Character Sets it says:
In the POSIX Standards, XBD section 6.1 titled Portable Character Set places this requirement from the C Standard on all locales supported by a system conforming to the POSIX Standards or to the more stringent requirements of the Single UNIX Specification.
So, the -n isn't needed in sort when all of the strings of digits being sorted are all the same length.
Although it doesn't matter in this case, note that the same can't be said for uppercase letters nor lowercase letters. Adding 0 through 26 to 'a' ('A') to get the lowercase (uppercase) letters in sequence happens to work in supersets of ASCII, but it won't work in EBCDIC. There are gaps between 'i' and 'j' ('I' and 'J') and between 'r' and 's' ('R' and 'S') in EBCDIC.
And with this 83..
actually i m not getting what i can call this, may be cheating/Not good way of programming but it also helps to reduce one count.
Still few more required..:wall: