Simple Calculator - kcalc

   

Korn Shell: Unix and Linux Programming Manual, Third Edition, The
By Anatole Olczak

Table of Contents
Appendix D.  Sample Korn Shell Scripts


Simple Calculator - kcalc

This Korn shell script implements a simple expr-like command. Arithmetic expressions are passed in as arguments, and the result is displayed. Parentheses for grouping must be escaped.

 #!/bin/ksh  #  #     kcalc - Korn Shell calculator  #  # Initialize expression  integer EXPR  # Check usage  if (($# == 0))  then        print "$0: Must provide expression arguments."        exit 1  fi  # Set/evaluate EXPR  ((EXPR=$*))  # Print result  print $EXPR 

       
    Top
     



    Korn Shell. Unix and Linux Programming Manual, Third Edition
    Korn Shell. Unix and Linux Programming Manual, Third Edition
    ISBN: N/A
    EAN: N/A
    Year: 2000
    Pages: 177

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net