Visit Our UNIX and Linux User Community


checking wether an inputed character is already in a variable


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers checking wether an inputed character is already in a variable
# 1  
Old 07-27-2009
checking wether an inputed character is already in a variable

Hi,

i have a variable which holds a variety of letters. eg,
Code:
var=qwertyuiop

what i want to do is determine wether an inputed letter is already stored inside the variable, so i can say to enter a new one.

i have been playing around using tr and grep but nothing seems to work at all.

Please help, i am in dire need of assistance
# 2  
Old 07-27-2009
It would appear that you, 602chrislys and strasner, at the least, are all working on the same sort of homework/coursework questions.

(
https://www.unix.com/unix-dummies-que...ser-input.html
https://www.unix.com/unix-dummies-que...-alphabet.html
)

I am guessing you have been tasked with writing some sort of hangman program....

Please refer to the rules, especially rule 6:
The UNIX and Linux Forums - Forum Rules

If I am mistaken I do apologise.
# 3  
Old 07-27-2009
Quote:
Originally Posted by Tytalus
It would appear that you, 602chrislys and strasner, at the least, are all working on the same sort of homework/coursework questions.

(
https://www.unix.com/unix-dummies-que...ser-input.html
https://www.unix.com/unix-dummies-que...-alphabet.html
)

I am guessing you have been tasked with writing some sort of hangman program....

Please refer to the rules, especially rule 6:
The UNIX and Linux Forums - Forum Rules

If I am mistaken I do apologise.
Yeesh, I'm not sure which is worse...that I helped one of these people, or that AFTER I gave an answer, two more people created posts to ask the exact same question...
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #560
Difficulty: Medium
Computers do exactly as they are told to do, except when they are an A.I.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Program to combine two lines in a file on checking the first character of each line

Hi, I have a requirement where I need to combine two lines in a file based on first character of each line in a file. Please find the sample content of the file below: _______________________ 5, jaya, male, 4-5-90, single smart 6, prakash, male, 5-4-84, married fair 7, raghavi, female,... (12 Replies)
Discussion started by: jayaP
12 Replies

2. Shell Programming and Scripting

Checking ^M character in file

i have the file <infile> with ^M charactrer. i just wnt to know through script whether the file have ^M character or not. Please let me know the script steps to check the same. Thanks in Advance Ganesh. (3 Replies)
Discussion started by: Ganesh L
3 Replies

3. UNIX for Advanced & Expert Users

Wether does it successful or unreachable?

Hi, all: How can I check what happen with my own NIC driver which response "successful" when local PC "ping" a remote linux PC but "unreachable" when it "ping" a remote windows XP PC? My writed driver runs in linux 3.0.4 kernel. thanks! li, kunlun (1 Reply)
Discussion started by: liklstar
1 Replies

4. Shell Programming and Scripting

Removing a character from a variable and assigning it to another variable?

Hi folks. I have this variable called FirstIN that contains something like this: 001,002,003,004... I am trying to assign the content of this variable into ModifiedIN but with the following format : 001 002 003 004...(changing the commas for spaces) I thought about using sed but i am not... (17 Replies)
Discussion started by: Stephan
17 Replies

5. UNIX for Dummies Questions & Answers

checking wether an input is using letters of the alphabet

afternoon forums. I need to get a way of testing as to wether an inputed character is part of the english alphabet. i have come up with the following code but its not working at all. until '] do echo This is not a Letter done any help would be beneficial to me. (1 Reply)
Discussion started by: strasner
1 Replies

6. Shell Programming and Scripting

checking variable has value - ksh

hi all, i have a shell (ksh) script where i am reading line by line from a grep command and i wanted to check if the grep command actually returned something or was null. i can do this by using -z : if ; then ..... but this forces me to do something when $myVariable is null when i... (3 Replies)
Discussion started by: cesarNZ
3 Replies

7. Shell Programming and Scripting

Selecting files between a user inputed date range

Hi all! I'm working on a KSH script to select files between a user inputed date range (stored in a variable) and then move them and unzip them. I'm stuck at how to get the files between the user inputed date range selected. Any help would be greatly appreciated! The files are as such: ... (6 Replies)
Discussion started by: kelldan
6 Replies

8. Shell Programming and Scripting

checking the value of the variable

Does anyone know the quick way to check if the variable contains only numeric characters, for example: A=123445 - correct B=#f123* - incorrect I am in ksh88i Thanks a lot for help -A (1 Reply)
Discussion started by: aoussenko
1 Replies

9. UNIX for Dummies Questions & Answers

read a variable character by character, substitute characters with something else

im having trouble doing this: i have a variable with 2 characters repeating e.g. aababbbaaaababaabbaabbba is there a way i can search the variable for a's and b's and then change a's to b's and b's to a's? im guessing its like getting the 1's compliment of the string im doing this in... (2 Replies)
Discussion started by: vipervenom25
2 Replies

10. Shell Programming and Scripting

[csh] checking for specific character ranges in a variable

I want to check if a zip code is valid, using a variable that stores the zipcode. I am not sure how I would do this in a script. I know that simply checking for the numerical range of the number will not work, because '1' would be '00001' in zip code format. I know when I am in shell, I can use... (5 Replies)
Discussion started by: userix
5 Replies

Featured Tech Videos