Script to generate names
Will Maier
willmaier at ml1.net
Fri Feb 3 12:43:31 PST 2006
On Fri, Feb 03, 2006 at 11:08:04AM +0100, Kristian Vaaf wrote:
> I'm looking for pointers on how to make a simple shell script that will
> generate new names based on words (one word per line) from two different
> files, and output these to a third file.
How bout this? Works on OpenBSD's sh; I assume it works on Free's sh
as well. Might take a while to run, though...
#!/bin/sh
notify () {
if [ ${VERBOSE} ]; then
echo "===> $*"
fi
}
VERBOSE=1
LIST1=/path/to/list1
LIST2=/path/to/list2
LIST3=/path/to/list3
NEWWORDCT=0
if [ ! -f "${LIST3}" ]; then
touch ${LIST3}
fi
for WORD1 in $(< ${LIST1}); do
for WORD2 in $(< ${LIST2}); do
echo "${WORD1}${WORD2}" >> ${LIST3}
echo "${WORD2}${WORD1}" >> ${LIST3}
NEWWORDCT=$((NEWWORDCT + 2))
done
done
sort ${LIST3} | uniq > ${LIST3}-sorted
notify "Created ${NEWWORDCT} new words in file ${LIST3}; a sorted version"
notify "can be found at ${LIST3}-sorted."
--
o--------------------------{ Will Maier }--------------------------o
| jabber:..wcmaier at jabber.ccc.de | email:..........wcmaier at ml1.net |
| \.........wcmaier at cae.wisc.edu | \..........wcmaier at cae.wisc.edu |
*------------------[ BSD Unix: Live Free or Die ]------------------*
More information about the freebsd-questions
mailing list