Shell Script to Calculate Simple Interest

  1. To create a new file in terminal write vi filename.sh
  2. Press i for edit mode
  3. First line in your shell scripts acts as a guideline on which shell to be used for running your script. Should be  #!/bin/bash
  4. write your code here

    #!/bin/bash
    echo enter principle amount
    read a #principle amount taken as a
    echo enter rate of interest
    read i #rate of interest taken as i
    echo enter time period in error
    read t #time period is taken as tinterest=$(echo "($a*$i*$t)/100" | bc -l ) #simple interest formula
    echo simple interest : $interest
  5. to save press esc + : + w + q

  6. To run bash filename.sh

Output: