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

I have published a blog before to do this at https://sunxiaoquan.wordpress.com/2015/02/06/bash-script-to-extract-structure-at-stationary-point-from-gaussian09-scan-log-file/. Recently, I did a lot scan for a ring structure. And for some scan, Gaussian tried thousand times to find the stationary points. The previous script is too slow to extract structure from huge log file (>100M). So I improved it, the speed can not compare with perl or python. But it’s enough for daily use.

```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 statoinary point step
((n=`grep "Z-Matrix orientation" \$log | wc -l`)) #get the total number of scan step

a=(`grep -n "Stationary point found" \$log | cut -f1 -d":"`)
b=(`grep -n "Z-Matrix orientation" \$log | cut -f1 -d":"`)
((p=0))
for ((i=0;i<\${#a[*]};i++));do
#echo i \$i p \$p
for ((j=\$p;j<\${#b[*]};j++));do
if (( \${b[\$j]} > \${a[\$i]} )); then
((jj=\$j-1))
(( c= \${b[\$jj]} + 4 + \$atom ))
((q=\$i+1))
cat \$log | head -"\$c" | tail -"\$atom" | cut -c 15-20,31- >> "\$head"_stationary_point"\$q".xyz
((p=\$j))
break;
fi
done
done