Scripting Life: Parsing geometries in GAMESS
Here is a script that will extract the last geometry from a GAMESS log file (optimization/saddle point run)
#!/bin/bash
# Proper header for a Bash script.
PARAMS=` grep 'TOTAL NUMBER OF ATOMS' $1 | tr -s ' ' | cut -d '=' -f 2`
let LINES=PARAMS+1
grep -A $LINES ' ATOM CHARGE X Y Z' $1 > .temp
echo ' $DATA '
tail -n $PARAMS .temp
echo ' $END '
Supply a log file to the script at the command line and the last geometry will be printed out.
Lets go over the code:PARAMS=` grep 'TOTAL NUMBER OF ATOMS' $1 | tr -s ' ' | cut -d '=' -f 2`
This line extracts the number of atoms and stores it in the variable PARAMS
The variable LINES stores the number of lines we need to grep AHEAD in order to acquire the coordinates of the geometry.grep -A $LINES ' ATOM CHARGE X Y Z' $1 > .temp
Greps the coordinates for each NSERCH and stores it in a file called .temp
The last three lines provides a convenient print out for pasting.
I'm sure there is a more elegant way of doing this with maybe sed or awk or perl.



























