LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 04-09-2013, 09:22 PM   #1
lcarrick
LQ Newbie
 
Registered: Apr 2013
Posts: 1

Rep: Reputation: Disabled
unix Scripting


I need help with scripting, im trying to get a user to enter two number between 1 and 5 and if they enter a number above 5 then i have to have a message show up that they have to enter a new number. then when they enter a number with in the ranges i have to add the numbers and divide by three. this is what i have so far.



case
echo "Please enter a number"
read num1
echo "Please enter a number"
read num2
if num1 -gt 5; then
echo "Please pick a number less than 5 for number 1"
else
echo "Thank you for entering number 1"
if num2 -gt 5; then
echo "Please pick a number less than 5 for number 1"
else
echo"Thank you for entering number 1"
esac
 
Old 04-09-2013, 10:42 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
sounds like homework...

And you didn't read the book either, nor the manpage on bash (sh depending on system).
 
Old 04-09-2013, 11:03 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Indeed; bookmark/read
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

Incidentally, please use code tags https://www.linuxquestions.org/quest...do=bbcode#code
 
Old 04-10-2013, 06:29 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,425

Rep: Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826Reputation: 2826
I would be curious to know what you think the 'case' statement is doing for you?
 
  


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
Unix scripting renaming files Jay5487 Linux - Newbie 4 03-24-2008 03:41 PM
UNIX scripting question christianunix Linux - Software 2 10-07-2007 01:38 PM
unix scripting lapthorn Programming 7 03-11-2004 10:03 AM
php and unix scripting murshed Programming 3 06-26-2003 04:56 PM
scripting the unix command script lmcthbe Linux - General 7 05-28-2003 03:49 PM


All times are GMT -5. The time now is 09:27 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration