Hi,
I have a log file and I have to find the preveous versions line count and current version's line count I assinged preLC and curLC as bellow. I am unable to substract from preLC-curLC, If I do the same in comand prompt I am able to see the o/p: like :
$ cat ARBLOGNODE1.TEMPlinecount | awk '{print $1}'
1297
if same in code :
preLC=`cat ARBLOGNODE1.linecount | awk '{print $1}'`
curLC=`cat ARBLOGNODE1.TEMPlinecount | awk '{print $1}'`
echo `cat ARBLOGNODE1.linecount | awk '{print $1}'`
echo `cat ARBLOGNODE1.TEMPlinecount | awk '{print $1}'`
echo "preLC=$preLC"
echo "curLC=$curLC"
dif=$curLC-$preLC
echo "Diffrence = "$dif
I am getting :
1297
1297
preLC = 1297
curLC = 1297
Diffrence = 1297-1297
I need 0 as o/p, whats wrong in my code?
redlotus72:
Hi,
I have a log file and I have to find the preveous versions line count and current version's line count I assinged preLC and curLC as bellow. I am unable to substract from preLC-curLC, If I do the same in comand prompt I am able to see the o/p: like :
$ cat ARBLOGNODE1.TEMPlinecount | awk '{print $1}'
1297
if same in code :
preLC=`cat ARBLOGNODE1.linecount | awk '{print $1}'`
curLC=`cat ARBLOGNODE1.TEMPlinecount | awk '{print $1}'`
echo `cat ARBLOGNODE1.linecount | awk '{print $1}'`
echo `cat ARBLOGNODE1.TEMPlinecount | awk '{print $1}'`
echo "preLC=$preLC"
echo "curLC=$curLC"
dif=$curLC-$preLC
echo "Diffrence = "$dif
I am getting :
1297
1297
preLC = 1297
curLC = 1297
Diffrence = 1297-1297
I need 0 as o/p, whats wrong in my code?
instead of dif=$curLC - $preLC
try dif=`expr $curLC - $preLC`
Sorry, its giving same answer...
its not working....
hey use
dif=`expr $curLC - $preLC`
I missed the required spaces...on both sides of minus operator.