LDP/LDP/guide/docbook/abs-guide/makedict.sh

43 lines
1.6 KiB
Bash
Raw Normal View History

2002-06-03 14:36:49 +00:00
#!/bin/bash
# makedict.sh [make dictionary]
2008-03-13 13:24:45 +00:00
# Modification of /usr/sbin/mkdict (/usr/sbin/cracklib-forman) script.
2002-06-03 14:36:49 +00:00
# Original script copyright 1993, by Alec Muffett.
#
# This modified script included in this document in a manner
#+ consistent with the "LICENSE" document of the "Crack" package
#+ that the original script is a part of.
# This script processes text files to produce a sorted list
#+ of words found in the files.
# This may be useful for compiling dictionaries
2008-03-13 13:24:45 +00:00
#+ and for other lexicographic purposes.
2002-06-03 14:36:49 +00:00
2012-11-27 14:56:18 +00:00
E_BADARGS=85
2002-06-03 14:36:49 +00:00
2008-03-13 13:24:45 +00:00
if [ ! -r "$1" ] # Need at least one
then #+ valid file argument.
2002-06-03 14:36:49 +00:00
echo "Usage: $0 files-to-process"
exit $E_BADARGS
fi
2011-08-29 23:59:19 +00:00
# SORT="sort" # No longer necessary to define
#+ options to sort. Changed from
#+ original script.
2002-06-03 14:36:49 +00:00
2012-11-27 14:56:18 +00:00
cat $* | # Dump specified files to stdout.
tr A-Z a-z | # Convert to lowercase.
tr ' ' '\012' | # New: change spaces to newlines.
2011-08-29 23:59:19 +00:00
# tr -cd '\012[a-z][0-9]' | # Get rid of everything
#+ non-alphanumeric (in orig. script).
tr -c '\012a-z' '\012' | # Rather than deleting non-alpha
#+ chars, change them to newlines.
2012-11-27 14:56:18 +00:00
sort | # $SORT options unnecessary now.
uniq | # Remove duplicates.
grep -v '^#' | # Delete lines starting with #.
grep -v '^$' # Delete blank lines.
2002-06-03 14:36:49 +00:00
2012-11-27 14:56:18 +00:00
exit $?