Generate a playful "acronym expansion" from input text by mapping each letter (in order) to a randomly selected dictionary word that starts with that letter.
- Readable output for multi-word input: prints one output line per input word
- Per-occurrence randomization: repeated letters can produce different words within the same run
- Input sanitization: splits input on whitespace to preserve word boundaries and removes non-alphabetic characters from each word before processing
- Title Case output: each generated word is capitalized (first letter uppercased)
- Efficient implementation: scans the wordlist once and performs all selection in
awk(no per-letter external pipelines) - Custom wordlists via
-w /path/to/wordlistor theWORDLISTenvironment variable
- Bash
awk- A wordlist file (default:
/usr/share/dict/words)
On many Linux systems, /usr/share/dict/words is provided by a package commonly named words (or similar). If your system does not have a default wordlist, provide one using -w or WORDLIST.
Clone the repository and make the script executable:
chmod +x acronymize.sh./acronymize.sh [-w WORDLIST] [text...]| Option | Description | Default |
|---|---|---|
-w PATH |
Use a custom wordlist | /usr/share/dict/words |
The WORDLIST environment variable can also be used to set the wordlist path. The -w flag overrides the environment variable.
Single word:
./acronymize.sh testMultiple words (quotes optional):
./acronymize.sh Make Acronyms Great AgainCustom wordlist using -w:
./acronymize.sh -w ./words.txt "hello world"Custom wordlist using WORDLIST:
WORDLIST=./words.txt ./acronymize.sh hello worldInput with non-alphabetic characters (they are stripped before processing):
./acronymize.sh "Hello, world!"Possible output:
Horizon Ember Lantern Lichen Orbit
Warden Orbit Rivulet Lantern Druid
- Each input word becomes one output line.
- Each letter in the input word becomes one output word.
- Non-alphabetic characters are removed from each input word before processing.
For each letter occurrence:
- The script selects a random dictionary word that begins with that letter.
- Repeated letters are randomized independently.
To reduce short-run repetition for the same starting letter, candidate words for a given letter are shuffled and consumed sequentially, then reshuffled when exhausted.
If no dictionary entry matches a given letter, the script emits a placeholder token: (no-match:x).
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Wordlist not readable |
2 |
Invalid usage (missing input or no alphabetic characters) |
Author: Leon "Avic" Simmons -- GitHub