Need help getting started simple simple shell script

Discussion in 'Programming/Scripts' started by dhonnoll78, Dec 17, 2007.

  1. dhonnoll78

    dhonnoll78 New Member

    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?
     
  2. ebal

    ebal New Member

    #!/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"
     

Share This Page