rm gap_222_T.dat
touch gap_222_T.dat
declare -i j
array=(300 500 700)
for j in ${array[@]}
do
  a=$(grep highest ZG-nscf_222_"$j".00K.out | awk '{print $7}')
  grep $a ZG-nscf_222_"$j".00K.out | head -1 > tmp
  awk '{print ($5+$6+$7+$8)/4}' tmp > VBM # average of 4 bands
  a=$(grep highest ZG-nscf_222_"$j".00K.out | awk '{print $8}')
  grep $a ZG-nscf_222_"$j".00K.out | head -1 > tmp
  awk '{print ($1+$2+$3+$4)/4}' tmp > CBM
  echo $j > T
  paste T VBM CBM > tmp2
  awk '{print $1, ($3-$2)}' tmp2 >> gap_222_T.dat
  rm T VBM CBM tmp*
done
