LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 08: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, 09:42 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
sounds like homework...

And you didn't read the book either, nor the manpage on bash (sh depending on system).
 
Old 04-09-2013, 10:03 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 05:29 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

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


Reply



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 02:41 PM
UNIX scripting question christianunix Linux - Software 2 10-07-2007 12:38 PM
unix scripting lapthorn Programming 7 03-11-2004 09:03 AM
php and unix scripting murshed Programming 3 06-26-2003 03:56 PM
scripting the unix command script lmcthbe Linux - General 7 05-28-2003 02:49 PM

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

All times are GMT -5. The time now is 06:38 AM.

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