Path: utzoo!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!xanth!mcnc!rti!trt From: trt@rti.rti.org (Thomas Truscott) Newsgroups: comp.misc Subject: Re: Your favourite UNIX pipe ? Summary: another one for the usenet pipeline Keywords: pipe piper pipest Message-ID: <3870@rtifs1.UUCP> Date: 29 May 90 19:22:23 GMT Article-I.D.: rtifs1.3870 References: <690@coma.UUCP> <24468@unix.cis.pitt.edu> <2487@rivm05.UUCP> Organization: Research Triangle Institute, RTP, NC Lines: 24 Here is a shell script that has a pipeline in it somewhere. Tom Truscott #! /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 wordlist=/usr/dict/words myguess=e guesses= while [ "$myguess" ]; do guesses=$guesses$myguess echo -n "I guess $myguess, new pattern: " read pattern srchpat=`echo "$pattern" | sed "s/\./[^$guesses]/g"` myguess=`grep "^$srchpat$" $wordlist | \ sed -e "s/[$guesses]//g" -e 's/\(.\)\(.*\)\1/\1\2/g' -e 's/./&\\ /g' | \ sort | uniq -c | sort -nr | \ sed -n -e 's/^.*\([^ ]\)$/\1/p' | sed 1q` done