Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 17th December 2007, 20:24
dhonnoll78 dhonnoll78 is offline
Member
 
Join Date: Dec 2006
Posts: 42
Thanks: 2
Thanked 0 Times in 0 Posts
Default Need help getting started simple simple shell script

Here is a simple shell script I am trying to write just for practice and getting started. The prloblem is, I don't know how to set up my math equation. Here is what I have so far
#!/bin/sh
#by Drew Honnoll
#Just a dumb script to practice user imput and screen oupt
NEWAGE=
GRANDCHILDREN=
echo "Please enter your name and press enter"
read name
echo "Please enter the number of children you have and press enter"
read children
echo "Please enter your age when you had your last child and press enter"
read age
echo "Now, $name if your children have 2 children each by the time they are at l
east 25"
echo "Then by the time you are $NEWAGE you will have $GRANDCHILDREN grandchildre
n"
Now every attempt I have made to set up GRANDCHILDREN and NEWAGE has failed I want NEWAGE to $age + 25 for the output and I want GRANDCHILDREN to $children * 2 but I can't get it to work. Dumb yeah I know but we all gotta start somewhere right?
Reply With Quote
Sponsored Links
  #2  
Old 18th December 2007, 13:05
ebal ebal is offline
Member
 
Join Date: Aug 2007
Posts: 36
Thanks: 0
Thanked 2 Times in 2 Posts
 
Default

#!/bin/bash
echo "Please enter your name and press enter"
read name
echo "Please enter the number of children you have and press enter"
read children
echo "Please enter your age when you had your last child and press enter"
read age
echo "Now, $name if your children have 2 children each by the time they are at least 25"
echo "Then by the time you are `expr $age + 25` you will have `expr $children \* 2` grandchildren"
__________________
http://ebalaskas.gr/wiki
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hoow to connect to sql server from a script shell pattchen Programming/Scripts 4 7th May 2007 23:01
need urgent help for writing shell script dips Programming/Scripts 8 3rd September 2006 20:40
Shell Script Need Help mphayesuk Programming/Scripts 4 27th June 2006 13:06
shell script Nnyan Programming/Scripts 4 24th June 2006 14:47
Need help for writing shell script erez Programming/Scripts 4 16th June 2006 15:23


All times are GMT +2. The time now is 08:33.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.