Debian Codegraph @

agram.sh

raw symbols SCIP
1 #!/bin/bash
2 # agram.sh: Playing games with anagrams.
3
4 # Find anagrams of...
5 LETTERSET=etaoinshrdlu
6 FILTER='.......' # How many letters minimum?
7 # 1234567
8
9 anagram "$LETTERSET" | # Find all anagrams of the letterset...
10 grep "$FILTER" | # With at least 7 letters,
11 grep '^is' | # starting with 'is'
12 grep -v 's$' | # no plurals
13 grep -v 'ed$' # no past tense verbs
14 # Possible to add many combinations of conditions and filters.
15
16 # Uses "anagram" utility
17 #+ that is part of the author's "yawl" word list package.
18 # http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
19 # http://bash.deta.in/yawl-0.3.2.tar.gz
20
21 exit 0 # End of code.
22
23
24 bash$ sh agram.sh
25 islander
26 isolate
27 isolead
28 isotheral
29
30
31
32 # Exercises:
33 # ---------
34 # Modify this script to take the LETTERSET as a command-line parameter.
35 # Parameterize the filters in lines 11 - 13 (as with $FILTER),
36 #+ so that they can be specified by passing arguments to a function.
37
38 # For a slightly different approach to anagramming,
39 #+ see the agram2.sh script.