Hi,
I am trying to calculate a few values using the below code but it dosent seem to be working.
for i in 1 2 3 4 5 6 7 8
do
j=`expr $i + 3`
x =`head -$j temp1|tail -1|cut -f24 -d","`
y =`head -$j temp1|tail -1|cut -f25 -d","`
c =`expr $x / $y`
echo "$c" >> cal_1
done
I am not getting any values in cal_1 file.
When I execute the script in verbose mode, I see below errors in each iteration:
x: not found
y: not found
c: not found
Can someone suggest a workaround ??
j=`expr $i + 3`
x =`head -$j temp1|tail -1|cut -f24 -d","`
y =`head -$j temp1|tail -1|cut -f25 -d","`
c =`expr $x / $y`
There should not be any space between the = and x,y,c
1 Like
i think the problem is with spaces
try removing them
for i in 1 2 3 4 5 6 7 8
do
j=`expr $i + 3`;
x=`head -$j temp1|tail -1|cut -f24 -d","`;
y=`head -$j temp1|tail -1|cut -f25 -d","`;
c=`expr $x / $y`;
echo "$c" >> cal_1
done
1 Like
Thank a lot both of you.
Valus are populating now.
Thanks a lot ! The issue is resolved