Greetings.
I would like to reverse a string using only the tools which are part of the Single UNIX Specification (POSIX). The list of UNIX utilities in that specification can be seen on Wikipedia:
http://en.wikipedia.org/wiki/List_of_Unix_utilities
In Linux and BSD I can just use the command
and feed input to it through standard input. However, 'rev' is not part of SOS.
So far, my best proposal is the following.
Code:
awk '{for(i=length($0);i>0;i--){printf("%c",substr($0,i,1))}}'
This program reverses the text provided to it on standard input, although it removes linebreaks if present.
In my specific scenario, I have a single word consisting of English characters only, with no spaces, punctuations, or hyphens.
I think the code looks hideous, and I have not found a more elegant way in my brief search. Any ideas?
Thanks in advance

Willard.