anagram


anagram is a command-line program to give all the sets of words that can be made by rearranging the letters of a word or phrase. For example:
	$ anagram martin guy
	rug at in my
	rug an it my
	rig at my nu
	rag it my nu
	gum ray tin
	mug ray tin
	gay rum tin
	gay nut rim
	[... 44 lines deleted ...]
	anti rug my
	unity gram
	angry it mu
	rangy it mu
	amity rung
	mutiny rag
  
By default, it reads its list of candidate words from the system word list at the location /usr/dict/words. To supply your own (or another) wordlist, just provide it on standard input:
	$ anagram martin guy < italian_wordlist
  
It takes a few option flags to make the output more or less voluminous, for which it prints a help message if you call it with no parameters.

Building

anagram is a simple C program for Unix that uses little more than the standard library and it should compile and run on any POSIX-compliant system.

Download the source code and on normal Unix systems the incantation

	cc -o anagram anagram.c
  
will produce a file called "anagram" that you can run.

If you are lucky, the simpler command

	make anagram
  
will do the same thing.

History

I wrote this program in 1985 and posted it to the USENET newsgroup net.sources (in December of that year I believe) though the original posting seems to have been be lost.

In the late 80's it was included in the BSD Unix software distribution for High Level Hardware's "Orion Mk0" superminicomputer.

Bugs

If an anagram contains a word twice, there will be duplicate lines. For example:
	$ anagram peter collinson
	...
	respect ill no no  
	respect ill no on  <--
	respect ill on no  <--
	respect ill on on    
	...
  
The best anagrams are devised by clever people, not by programs.
Martin Guy (a Grimy Nut) <martinwguy@yahoo.it>, 14 September 2005.
SourceForge.net Logo