title: How to read from two files in the same time shell
body: <p>I have two files,</p>
  
  <pre><code>A
  
  john 1 2 3 4 5 6 7
  Ely 10 9 9 9 9 9 9
  Maria 3 5 7 9 2 1 4
  Rox 10 10 10 10 10 10 10
  
  B 
  john 7.5
  Ely 4.5
  Maria 3,7
  Rox 8.5
  </code></pre>
  
  <p>What i want to do is create another file with only the persons who have in file A their average greater or equal with the 8.5 and in B their mark also greater or equal to 8.5, so in my example the C file would contain only Rox because only she fulfil the criteria.</p>
  
  <p>I have this</p>
  
  <pre><code>#shell program
  echo "Fiserul are numele $1"
  filename=$1
  filename2=$2
  echo ""&gt;temp.txt
  touch results
  compara="8.5"
  cat $filename | while read -r line
  do
      nota=0
      media=0
      echo " $line"
      rem=$( echo "$line"| cut -f 2- -d ' ')
      for word in $rem 
      do
          echo "$word"
          nota=$(($nota+$word))
          echo "Nota=$nota"
      done
      media=$(($nota / 7))
      if [ "$(echo $media '&gt;=' $compara | bc -l)" -eq 1 ];
      then 
          nume=$( echo "$line"| cut -f 1 -d ' ')
          echo "$nume $media" &gt;&gt; temp.txt
      fi
      echo "Media : $media"
  done
  cat $filename2 | while read -r line
  do
  </code></pre>
  
  <p>so I have in the temp.txt files the persons who fulfil the criteria for file A but my question is how can i compare them with the persons from filename2 and create "results" from them ?
  I've tried with two while loops but i get an error, could someone please help ? 
  Thanks!</p>