#!/bin/bash
rm -f gap.txt
avggap=0
nfile=0
for inf in *.fch
do
((nfile++))
echo Processing $inf "..."
Multiwfn $inf -silent << EOF > out.txt
0
q
EOF
gapthis=$(grep "HOMO-LUMO gap" out.txt |awk '{print $5}')
echo $inf: $gapthis eV >> gap.txt
avggap=$(echo $avggap+$gapthis | bc -l)
rm -f out.txt
if [[ $nfile -eq 1 ]] ; then
gapmin=$gapthis
namemin=$inf
else
if [[ $(echo "$gapthis < $gapmin" | bc) -eq 1 ]] ; then
gapmin=$gapthis
namemin=$inf
fi
fi
done
echo | awk '{printf ("\n%s %10.6f %s\n","Average HOMO-LUMO gap:",t1/t2," eV")}' t1=$avggap t2=$nfile >> gap.txt
echo "Done! Result has been outputted to gap.txt in current folder"
echo "Totally" $nfile "files were processed"
echo $namemin has minimal gap of $gapmin eV >> gap.txt
¾Ã¾Ã¾«Æ·¹ú²ú99¾Ã¾ÃÏã½¶