Path: utzoo!attcan!uunet!mailrus!accuvax.nwu.edu!nucsrl!telecom-request From: gtisqr!toddi@nsr.bioeng.washington.edu (Todd Inch) Newsgroups: comp.dcom.telecom Subject: Translating Alpha Phone Numbers Message-ID: <8367@accuvax.nwu.edu> Date: 28 May 90 22:36:05 GMT Sender: news@accuvax.nwu.edu Reply-To: Todd Inch Organization: Global Tech Int'l Inc. Lines: 36 Approved: Telecom@eecs.nwu.edu X-Submissions-To: telecom@eecs.nwu.edu X-Administrivia-To: telecom-request@eecs.nwu.edu X-Telecom-Digest: Volume 10, Issue 394, Message 2 of 10 In article <8294@accuvax.nwu.edu> mailrus!uflorida!rm1!bapat@ uunet.uu.net (Bapat) want's to convert phone numbers with letters to numeric, and has access to a Unix machine. The following should do it. "tr" will translate a character in the first string to a corresponding character in the second string. BTW: tr "[a-z]" "[A-Z]" will convert lower-case strings to all uppercase, which is irrelevant to this topic, but useful. -------------------- cut here --------------------------- : # Shell script to convert alpha-containing phone number to all numeric. # Put phone number on command line or wait for prompt. # if [ -z "$1" ] then echo "Phone number containing characters? \c" read phnnum else phnnum="$1" fi if echo "$phnnum" | grep 'q\|Q\|z\|Z' > /dev/null then echo "There's no Q or Z on the phone dial." exit 1 fi echo "$phnnum" | tr "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVwWxXyY" \ "222222333333444444555555666666777777888888999999" exit -------------------- cut here --------------------------- Todd Inch, System Manager, Global Technology, Mukilteo WA (206) 742-9111 UUCP: {smart-host}!gtisqr!toddi ARPA: gtisqr!toddi@beaver.cs.washington.edu