Hmmm...
The 'one duplicated letter' problem is not particularly fun to solve with regular expressions, or even bash, for that matter -- it would be easier to use a full programming language. Perl would be particularly easy to use, in this case.
I would do this:
1. Run the dictionary through sed to only leave five letter words.
2. Run a perl script to only leave words that have only one duplicated letter.
For the perl script, I would use a hash (
http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/) with the letters as a key and the number of occurrences as the value. Then, scan through the hash and check to see if only one value is >= 2. If that is the case, split out the characters as necessary, sort the other three characters with three conditional swaps, and print the output in the format you want.
This sounds like either homework to me or a bizarre analysis of the English language. What are you using this for?
- thobbs