Subtract two variable

plz help me in simple calculation.

Have to substract two variable (in Bytes) and change the output into MB.

A=`more /tmp/size_info_old.out |awk NR==3`
echo "$A" > /tmp/rav/A.out
B=`more /tmp/size_info.out |awk NR==3`
echo "$B" > /tmp/B.out
C=$(((B-A))/1024/1024)
 
echo "$C" /tmp/final_report

or any other simple way to do this

Thanks in Advance

try sth like this..

awk 'NR==3{A=$0}
	FNR==3 && NR > 3{B=$0}
	END{print (B-A)/(1024*1024)}' /tmp/size_info_old.out /tmp/size_info.out
1 Like

Another way,

awk 'FNR==3 { x[f++]=$0 } END {print (x[1]-x[0])/(1024*1024)}' /tmp/size_info_old.out /tmp/size_info.out