Home arrow Shell Programming arrow Adding Two Numbers Using UNIX Shell Scripting Language
Adding Two Numbers Using UNIX Shell Scripting Language PDF  
Digg Reddit Ma.gnolia Stumble Upon Facebook Twitter Google Yahoo! MyWeb Furl" BlinkList Technorati Mixx Bookmark
To add two numbers we can pipe an echo to the bc app from a shell script:

Example of adding two numbers
  1. #!/bin/sh
  2.  
  3. a=10
  4. b=20
  5. c=`echo $a+$b | bc`
  6. echo "c="$c

 

 
< Prev   Next >

Other BSD Systems

OpenBSD

Polls

Best BSD firewall?