crasho2001
Technical User
Hi,
I have two big files.
File1 has 2 columns. (id,num). It has all ids.
File2 has 1 column.(id). It has some ids.
If File2 id matches File1 id than count num.
I used the script below. But it takes too much time. How can make it faster?
count=0
for list in `cat File2`
do
count1=`grep $list File1|awk '{print $2}'`
count=`expr $count + $count1`
done
echo $count
I have two big files.
File1 has 2 columns. (id,num). It has all ids.
File2 has 1 column.(id). It has some ids.
If File2 id matches File1 id than count num.
I used the script below. But it takes too much time. How can make it faster?
count=0
for list in `cat File2`
do
count1=`grep $list File1|awk '{print $2}'`
count=`expr $count + $count1`
done
echo $count