| 1 | #!/bin/bash |
| 2 | # makedict.sh [make dictionary] |
| 3 | |
| 4 | # Modification of /usr/sbin/mkdict (/usr/sbin/cracklib-forman) script. |
| 5 | # Original script copyright 1993, by Alec Muffett. |
| 6 | # |
| 7 | # This modified script included in this document in a manner |
| 8 | #+ consistent with the "LICENSE" document of the "Crack" package |
| 9 | #+ that the original script is a part of. |
| 10 | |
| 11 | # This script processes text files to produce a sorted list |
| 12 | #+ of words found in the files. |
| 13 | # This may be useful for compiling dictionaries |
| 14 | #+ and for other lexicographic purposes. |
| 15 | |
| 16 | |
| 17 | E_BADARGS=85 |
| 18 | |
| 19 | if [ ! -r "$1" ] # Need at least one |
| 20 | then #+ valid file argument. |
| 21 | echo "Usage: $0 files-to-process" |
| 22 | exit $E_BADARGS |
| 23 | fi |
| 24 | |
| 25 | |
| 26 | # SORT="sort" # No longer necessary to define |
| 27 | #+ options to sort. Changed from |
| 28 | #+ original script. |
| 29 | |
| 30 | cat $* | # Dump specified files to stdout. |
| 31 | tr A-Z a-z | # Convert to lowercase. |
| 32 | tr ' ' '\012' | # New: change spaces to newlines. |
| 33 | # tr -cd '\012[a-z][0-9]' | # Get rid of everything |
| 34 | #+ non-alphanumeric (in orig. script). |
| 35 | tr -c '\012a-z' '\012' | # Rather than deleting non-alpha |
| 36 | #+ chars, change them to newlines. |
| 37 | sort | # $SORT options unnecessary now. |
| 38 | uniq | # Remove duplicates. |
| 39 | grep -v '^#' | # Delete lines starting with #. |
| 40 | grep -v '^$' # Delete blank lines. |
| 41 | |
| 42 | exit $? |