############################## -*- Mode: sh -*- ############################# ## phonecombo -- print all the letter combinations (2=ABC, 3=DEF ...) of a ## phone number ## Copyright : http://www.fsf.org/copyleft/gpl.html ## Author : Dan Jacobson -- http://jidanni.org/ ## Created On : Jul 2001 ## Last Modified By: Dan Jacobson ## Last Modified On: Fri Mar 22 19:04:01 2002 ## Update Count : 104 ## Status : worked with bash 2.05 ############################################################################### #input example: 25854780 #output: AJTJGPT0 ...[2187 lines] #note: there are many other programs out there that probably do what #you want instead, e.g., number2word, which does a spell check to find #English words in there, etc. #I just wanted to see if I could print out all those combos... #Where I live, the phones don't have ABC... etc. anyway. # #note that the amount of output is 3 to the power of number of #digits given, excluding in the total any phone digits '1' and '0' #[but now '7' and '9' have 4 letters...] #.e.g. phone_no 25854780 will give the same number of output lines as #2585478, i.e. 3**7=2187 : ${1?} case "$*" in *[^0-9]*) echo $0: usage: $0 phone_number \(one number only\) >&2 ;exit 44 esac set $(echo $1|sed 's/./& /g') for i do let ++x; tab=$tab\ #tab: looks nice while debugging head="$head "'for m'$x' in ${letters[${phone_no['$x']}]} '$tab'do' #newline: can then use bash line # when debugging middle=$middle'${m'$x'}' tail=$tail'; done' done letters=("0" "1" "A B C" "D E F" "G H I " "J K L" "M N O" "P Q R S" "T U V" "W X Y Z") #oh great. new style # "P R S" "T U V" "W X Y") #traditonal style phone_no=(dummy $*) eval "$head echo $middle$tail" #by the way, here's how I found some words for my wife's phone number, #22394562: first I first did some tirials by just looking at the raw results, #on 22, 223, and found "BAD", then did #phonecombo 94562|tee /tmp/v|ispell -l|sort|diff - /tmp/v #> WILMA #OK!, so now she's "BAD-WILMA"! Indeed, further investigations found her #cell phone to be ...ORGY-88 ! #I did the same on my 25854780 and found "ALT-LIST-0" #echo ALT-LIST-0|sed y/ABCDEFGHIJKLMNOPRSTUVWXY/222333444555666777888999/ #new: sed y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/22233344455566677778889999/ #converts it back, to check #what number to request for your new line? #echo 1-800-FUC...