The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 03-28-2007
krishna_sicsr krishna_sicsr is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 25
Unhappy How To Calculate

I have 2 variables in my shell scripts in which i am using awk and calculating 2 files and getting 2 different variable called in_total and out_total. I want to subtract one variable from another so plz tell me how i can do that.

Example is:

cat in_file | awk -F: '{
in_total += $1 * 86400 + $2 * 3600 + $3 * 60 + $4
}'

cat out_file | awk -F: '{
out_total += $1 * 86400 + $2 * 3600 + $3 * 60 + $4
}'

so plz tell me how i can subtract out_total from in_total