Need help getting started simple simple shell script
OKAY I need help getting started with a simple and dumb shell script but we all have to start somewhere right?
Okay Here is what I have so far
#by Drew Honnoll
#Just a dumb script to practice user imput and screen oupt
echo "Please enter your name and press enter"
echo "Please enter the number of children you have and press enter"
echo "Please enter your age when you had your last child and press enter"
echo "Now, $name if your children have 2 children each by the time they are at least 25, then by the time you are $NEWAGE you will have $GRANDCHILDREN grandchildren"
What I don't know and what every attempt of mine has failed is getting NEWAGE and GRANDCHILDREN set up
NEWAGE needs to be a math equation of $age + 25
and GRANDCHILDREN needs to be an equation of $children * 2 How do I go about doing that?
Thanks but this is a korn shell looks like anytime I say use a command not found I get ksh :wrongcommand: not found
Your first line (#!/bin/sh) should be telling the computer to execute the remainder of the script as if it were in the Bourne shell (sh). Most Linux distributions have a link from sh to bash (Bourne Again Shell). (This is why I had assumed that you were using bash.) If you want to run it in Korn, it should read
Did you remember to change the permissions on your script so that it can be run? If your script is say age.sh, then you would want to add execute permissions to it.
I would use the let function built into bash:
# No need to declare variables in bash unless you want to specify type.
I put in the echoes to check it.
Never just accept the default shell, always specify exactly which one you want used. That way you know which syntax applies...
|All times are GMT -5. The time now is 01:02 PM.|