Path: utzoo!yunexus!hydroesm!jtsv16!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.misc Subject: Re: Your favourite UNIX pipe ? Message-ID: <6740@star.cs.vu.nl> Date: 30 May 90 00:21:35 GMT Article-I.D.: star.6740 References: <690@coma.UUCP> <24468@unix.cis.pitt.edu> <2487@rivm05.UUCP> <3870@rtifs1.UUCP> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Informatika, Amsterdam, The Netherlands Lines: 47 In article <3870@rtifs1.UUCP>, trt@rti.rti.org (Thomas Truscott) writes: )... ) myguess=`grep "^$srchpat$" $wordlist | \ ) sed -e "s/[$guesses]//g" -e 's/\(.\)\(.*\)\1/\1\2/g' [...] ^^^^^^^^^^^^^^^^^^^^^^^^ Why? Anyway, a nice script, Tom! What do you think of the following modified version? --------------------cut here-------------------- #!/bin/sh # you pick a word, e.g. "hangman". # if antihang guesses "a", the new pattern is ".a...a.". # if antihang then gueses "t", the new pattern is ".a...a." (no change). # antihang fails on words not in /usr/dict/words # Original: Tom Truscott # Modifications: Maarten Litmaath wordlist=/usr/dict/words myguess=e guesses= NL=' ' while : do guesses=$guesses$myguess echo -n "I guess $myguess, new pattern: " read pattern case $pattern in *.*) srchpat=`echo "$pattern" | sed "s/\./[^$guesses]/g"` myguess=` sed -e "/^$srchpat$/!d" -e "s/[$guesses]//g" \ -e 's/./&\\'"$NL/g" -e 's/.$//' $wordlist | sort | uniq -c | sort -nr | sed -e 's/.*\(.\)$/\1/' -e q ` ;; *) break esac done -- "COBOL is the revenge of some witch burned |Maarten Litmaath @ VU Amsterdam: in Salem, [...]" (Bill Davidsen) |maart@cs.vu.nl, uunet!cs.vu.nl!maart