How to bring together two inputs in case?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to bring together two inputs in case?
# 1  
Old 04-24-2015
How to bring together two inputs in case?

Hi guys,

im newbie, im trying something, but cannot figure out how to bring together case with 2 inputs.
Something like "enter your name" and "enter your age".

I had idea but dont now how to finish it as I said i'm just a beginner.

Code:
#!/bin/bash
echo "Name"
echo -n "Enter your name: "
read name
echo -n "enter your age: "
read age
echo
case $name,$age in
"Thomas Muller"|35) echo "you are too old" ;;
"Luka modric"|28) echo "you are boring" ;;
esac

when i try it nothing happens, I had idea how i can solve it in pascal nad converted it to bash, but i really dont know if it is possible.

Code:
if [ "$name" == "name" ] && [ "$age" == "age" ]; then 
  echo "$age";

# 2  
Old 04-24-2015
You want to check for the combination of the two?

Something like:
Code:
$ name="carlo"
$ age="old"
$ case ${name}${age} in
> "carloold") echo "You are old and grumpy" ;;
> *) echo "You're not me" ;;
> esac
You are old and grumpy

# 3  
Old 04-24-2015
Quote:
Originally Posted by CarloM
You want to check for the combination of the two?

Something like:
Code:
$ name="carlo"
$ age="old"
$ case ${name}${age} in
> "carloold") echo "You are old and grumpy" ;;
> *) echo "You're not me" ;;
> esac
You are old and grumpy

Yes dear Carlo something like this, if he enter the name for exmaple Thomas Muller, but the age is not correct the echo "you are too old" will not appear.

i'm just learning bash and looking for tutorials. am I on the right way? Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change first letter of a word from lower case to upper case

Hi all, I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like . ; : ! ?I found the following command sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
Discussion started by: georgi58
7 Replies

2. Shell Programming and Scripting

Conversion from Upper Case to Lower Case Condition based

Hello Unix Gurus : It would be really appreciative if can find a solution for this . I have records in a file . I need to Capitalize the records based on condition . For Example i tried the following Command COMMAND --> fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Discussion started by: tsbiju
12 Replies

3. Shell Programming and Scripting

[Solved] Change Upper case to Lower case in C shell

Is there a command that can switch a character variable from UPPER case to lower case? like foreach AC ( ABC BCD PLL QIO) set ac `COMMAND($AC)` ... end Thanks a lot! (3 Replies)
Discussion started by: rockytodd
3 Replies

4. Shell Programming and Scripting

sed ignoring case for search but respecting case for subtitute

Hi I want to make string substitution ignoring case for search but respecting case for subtitute. Ex changing all occurences of "original" in a file to "substitute": original becomes substitute Origninal becomes Substitute ORIGINAL becomes SUBSTITUTE I know this a little special but it's not... (1 Reply)
Discussion started by: kmchen
1 Replies

5. Shell Programming and Scripting

data array needs to change upper case to lower case

Hi all, i have a data array as followes. ARRAY=DFSG345GGG ARRAY=234FDFG090 ARRAY=VDFVGBGHH so on.......... i need all english letters to be change to lower case. So i am expecting to see ARRAY=dfsg345ggg ARRAY=234fdfg090 ARRAY=vdfvgbghh so on........ If i have to copy this data in... (8 Replies)
Discussion started by: usustarr
8 Replies

6. Shell Programming and Scripting

Script to Convert Upper case to Lower case

Hi All I have a script which extracts values from a Database (A persons name) and puts it into a variable in my script IE: $NAME However the Value in the DB is all in uppercase and contains the users first name and last name EG: > echo $NAME GRAHAM BOYLE > What I need is only the... (7 Replies)
Discussion started by: grahambo2005
7 Replies

7. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

8. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies
Login or Register to Ask a Question