From: Philippe Doucet <philippedoucet@hotmail.com> To : <linuxsa@linuxsa.org.au> Date: Sat, 31 Mar 2001 17:52:28 -0000
> > I have redhat 6.2 running bash > I`m trying to writte a hangman script and I`m stuck with this problem. > > I have a file containing spaced out underscore ie. - - - - - - - > > The number of underscores represent the number of letter of the word > to be discovered. > > Once a user makes a guess at the word, let`s say the letter A, and the > user is right, I want that letter to replace the appropriate > underscore. so let`s say that the letter A was the second letter of > the word, after the user guesses the letter A, the file would be > appended to - A - - - - - need ... more ... info .... how are you storing the answer word? do you know that the 'a' is the second letter? What if there are more than 1 'a' iin the answer? How do you store that info? here's a tip, shell programming regular expressions sucks I reckon. I say regexp because that's how I'd do it. make a regexp that replaces the 2nd instance of "- " pattern with "A" -- Jake Hawkes B.Eng, (CSE) Paul's Law: You can't fall off the floor.Philippe Doucet wrote:Hmmm ok...well here it is...yes if there is more then one A i want it to replace it as well...so in my command i'll be using some $1 $2 $3....for sure the word is stored in a file, that file is translated into all underscore and stored in another file. Now I prompt the user to enter a letter, I check if that letter exist in the word and also where it is situated in the word, that is all fine. Now i'm at where I take that letter and replace it in the right order into the underscore file. I was thinking of regular expression but all i can find is commands that will append line by line...since my whole word is on the same line i don't know how to act on each individual underscore. I"m sorry for the way i'm giving out information but i'm quite new to bash...like 4 weeks new ...i'm pretty sure a regexp would be the answer.
Phil
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
-- LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au To unsubscribe from the LinuxSA list: mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject