Hello Linux experts,
I am attempting to extract segments of a large output file and put each segment into its own file.
My script:
Code:
#!/bin/bash
#pull out structures from Gaussian09 Scan.
for ((x=43, y=44; x<1200, y<1200; x+=43, y+=46))
do
grep -A 43 'Z-MATRIX' structures.out | head -$x | tail -39 > tmp_Zmatrix
CHI="`grep '11 11 C' tmp_Zmatrix | awk '{print $11}' | sed 's/.$//g'`"
EPSILON="`grep '15 15 C' tmp_Zmatrix | awk '{print $11}' | sed 's/.$//g'`"
ZETA="`grep '32 32 O' tmp_Zmatrix | awk '{print $11}' | sed 's/.$//g'`"
echo $CHI $EPSILON $ZETA
echo 39 > ppa18_chi$CHI\_epsilon$EPSILON\_zeta$ZETA.xyz
echo ppa18_chi$CHI\_epsilon$EPSILON\_zeta$ZETA >> ppa18_chi$CHI\_epsilon$EPSILON\_zeta$ZETA.xyz
grep -A 44 'Z-Matrix orientation:' structures.out | head -$y | tail -39 | awk '{print $2, $4, $5, $6}' | sed -e 's/^1 /H /g' -e 's/^6/C/g' -e 's/^7/N/g' -e 's/^8/O/g' -e 's/^15/P/g' >> ppa18_chi$CHI\_epsilon$EPSILON\_zeta$ZETA.xyz
rm tmp_Zmatrix
done
The problem, I think, is in the for loop title (something about different steps being used). I used the "echo" line as a function check. As you can see, it skips certain values (the first two columns shouldn't change):
Code:
62.990 179.970 -179.140
62.990 179.970 -164.740
62.990 179.970 -150.340
62.990 179.970 -135.940
62.990 179.970 -121.540
62.990 179.970
62.990 179.970
62.990 179.970
62.990 179.970 -78.340
62.990 179.970 -63.940
62.990 179.970 -49.540
62.990 179.970 -35.140
62.990 179.970 -20.740
62.990 -6.340
62.990 8.060
22.460
179.970 36.860
179.970 51.260
62.990 179.970 65.660
62.990 179.970 80.060
62.990 179.970 94.460
62.990 179.970 108.860
62.990 179.970 123.260
62.990 179.970 137.660
62.990 179.970 152.060
62.990 179.970 166.460
I have checked the file structures.out and the data is there, but the script isn't extracting and reporting like it should. I don't understand why it does this for some lines, and not others.
How can I change the script to get all values to appear?
Thanks for your expertise!
-Dave
Bookmarks