LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-14-2004, 04:54 AM   #1
Alexander.s
Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Rep: Reputation: 15
i want to make a script with case.esac


I know how to do regular the ones

#!/bin/bash
NUM=$(( RANDOM % 10 ))
case $NUM in

0) echo "zero"
1) echo "one"
2 bla bla
3 bla
4 bla
5 bla
6 bla
7 esac
8
9
*
esac

But how do i use the read command in this
i want it to read a number and say it in letters
as when you type 5 it will echo five

thanks!
 
Old 12-14-2004, 05:22 AM   #2
mjuhannus
Member
 
Registered: Sep 2004
Location: Finland
Distribution: Ubuntu 10.04, Debian 5, OpenSUSE 11.3
Posts: 60

Rep: Reputation: 15
Hi

You just need to put line read NUM in it.

Here's an example:

Code:
#!/bin/bash

#NUM=$((RANDOM % 10))
echo -n "Enter a number: "
read NUM
case $NUM in

0) echo Zero ;;
1) echo One ;;
2) echo Two ;; 
3) echo Three ;;
*) echo Bigger than Three ;;
esac

Last edited by mjuhannus; 12-14-2004 at 05:27 AM.
 
Old 12-14-2004, 05:24 AM   #3
mjuhannus
Member
 
Registered: Sep 2004
Location: Finland
Distribution: Ubuntu 10.04, Debian 5, OpenSUSE 11.3
Posts: 60

Rep: Reputation: 15
oops, an error in the code

the case line of course without the word 'his' in the end.

Well actually i can edit the messages later so i removed it and this post useless

Last edited by mjuhannus; 12-14-2004 at 05:26 AM.
 
Old 12-14-2004, 05:29 AM   #4
Alexander.s
Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Slackware, Gentoo!
Posts: 115

Original Poster
Rep: Reputation: 15
np i was just going to say i figured it out :P

thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
is it possible to make apache2 non-case sensitive snip128 Linux - Newbie 1 07-15-2005 05:00 PM
change case of a string (TOUPPER) in shell script raees Linux - Software 3 05-03-2005 02:13 PM
help changing case on arguments to bourne shell script Maldain Programming 2 05-03-2005 10:18 AM
Upgrading to X11R6.8.0...Just a case of removepkg and make world? SBing Slackware 14 09-13-2004 02:10 AM
Do not stop or exit from a script in case of error. philipina Linux - General 4 07-02-2004 06:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration