Solved

pattern matchin help needed

Posted on 2007-11-16
2
308 Views
Last Modified: 2010-04-21
Hi guys i've been tryin to write a hangman game unix script and i've got a bit stuck on the hardest bits no. I'm first tryin to get a way to way to check if the inputed letter matches the other letters already inputed.

eg lets say the user has already inputed
"stored_letters=gaeop"

if they try to input "user_input=a" i need to refuse that entry since they have already entered that letter. I'm thinkin the way to do this is by cutin each letter of stored_letter and checking it aginstuser_input in a whle loop. My problem is i cant seem to write the code for this you hlp will be well appriciated.

thnx in advance
0
Comment
Question by:DSwiftie
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 350 total points
ID: 20303020
stored_letters=gaeop
user_input=a
case $user_input in
 [$stored_letters] ) echo already entered that letter ;;
esac
0
 

Author Comment

by:DSwiftie
ID: 20305145
thankyou very much that helped alot m8 cheers
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now