Article 8558 of soc.roots: Path: murdoch!uvaarpa!darwin.sura.net!jvnc.net!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!crl!ferrari!scott From: scott@ferrari.LABS.TEK.COM (Scott Huddleston) Newsgroups: soc.roots Subject: soundex from Unix Message-ID: <3395@crl.LABS.TEK.COM> Date: 22 Jan 92 02:08:18 GMT References: <9201131930.AA00522@rcrisp.uark.edu> <1992Jan14.184836.15662@ssd.dl.nec.com> <1992Jan16.183434.27481@spectrum.CMC.COM> Sender: news@crl.LABS.TEK.COM Reply-To: scott@ferrari.LABS.TEK.COM (Scott Huddleston) Organization: Computer Research Laboratory, Tektronix, Inc., Beaverton OR Lines: 35 For Unix users, the following shell script will calculate soundex codes from the shell. Copy the gobblygook below the "cut here" line into a file named "soundex" and make it executable (chmod +x soundex). Then you can issue "soundex" as a Unix command. Just give it a list of names you want the codes for. E.g., "soundex Huddleston Manis Pfister" gives Huddleston H342 Manis M520 Pfister P236 Thanks to Lar Poulson(?)'s perl example for inspiring me to write this. I don't speak much perl, but I think Lar's example requires you to write a perl program to use it. -------------- cut here --------------------------- #! /bin/sh # calculate soundex codes for a list of arguments for name in $*; do init=`echo $name | sed 's/^\(.\).*/\1/' | tr a-z A-Z` tail=`echo $name | tr A-Z a-z | sed ' s/[bvfp][bvfp]*/1/g s/[cgjkqsxz][cgjkqsxz]*/2/g s/[dt][dt]*/3/g s/ll*/4/g s/[mn][mn]*/5/g s/rr*/6/g s/^.\([a-z1-6]*\)/\1000/ s/[aehiouwy]//g s/^\(...\)[0-6]*/\1/ '` echo $name $init$tail done -- Scott Huddleston scott@crl.labs.tek.com