i=1 cnt=\`wc -l wordfile | cut -c 6-7\` echo $cnt cp wordfile filefor22 while [ $i -le $cnt ] do str=\`head -1 filefor22\` cnt1=\`grep -c $str $1\` echo $str $cnt1 ((c=$i+1)) tail +$c wordfile > filefor22 let i++ done -------------------------------------------------------------------------------- output: $ cat wordfile apple mango banana $ cat wordfile1 apple chickoo apple banana $ sh27 wordfile1 3 apple 2 mango 0 banana 1