# BASH script to extract structure at stationary point from Gaussian09 scan log file.

I am using Gaussian 09 to do dihedral, bond and angle scan now. My lab does not have Gaussian View, and sometimes I need to show the scan procedure or analyze them. QMTool in VMD shows all the structure rather than the stationary structures. So I write this script with BASH to do this job. The script does not have high efficiency but enough for daily demand.

When I paste the script here, it lost the format 😦     But it works well.

1.Source ./extract_structure.sh.

2.Type the name of log file with the extension, eg Scan.log.

3.The extracted structures (xyz format) will be stored in a folder with the same name of the log file, eg Scan.

4.A VMD Tcl/Tk script will generate in the folder. The name is combine.tcl.

5.Open VMD and its Tk console and type source combine.tcl. Or simply type vmd -e combine.tcl. VMD will load all the structure as a trajectory. And you may analyze them now.

########################################################

```read -p "Gaussian log file " log
((atom=`grep "NAtoms=" \$log | head -1 |cut -f2 -d"N" | cut -f2- -d" "`))
head=`cat \$log | head -3 | tail -1 | cut -f1 -d"." | cut -f2 -d"="`
((m=`grep "Stationary point found" \$log | wc -l`)) #get the total number of stationary point step
((n=`grep "Z-Matrix orientation" \$log | wc -l`)) #get the total number of scan step

for ((i=1;i<=\$m;i++));do
((a=`grep "Stationary point found" \$log -n | cut -f1 -d":" | head -"\$i" | tail -1`));#echo a=\$a
for ((j=\$n;j>=1;j--));do
((b=`grep "Z-Matrix orientation" \$log -n | cut -f1 -d":" | head -"\$j" | tail -1`))
if (( \$b < \$a ));then
(( c = b + 4 + \$atom ));#echo b=\$b c=\$c
echo \$atom > "\$head"_stationary_point"\$i".xyz
cat \$log | head -"\$c" | tail -"\$atom" | cut -c 15-20,31- >> "\$head"_stationary_point"\$i".xyz
break
fi
done
done
for ((i=1;i<=\$m;i++));do
if (( \$i == 1 ));then
echo mol new "\$head"_stationary_point"\$i".xyz > combine.tcl
else