#!/bin/sh
l=1 #this should be your starting scan number
k=10 #this should be your ending scan number

#########DO NOT CHANGE BELOW THIS LINE#########
echo 'm=[\'x\',\'y\',\'z\'];' >> 1.txt
p=$(echo "scale=10; 4*a(1)" | bc -l)
while [ $l -le $k ]
do
a=$(awk '{if(NR==5)print$1}' run-"$l"/XPARM.XDS)
b=$(awk '{if(NR==5)print$2}' run-"$l"/XPARM.XDS)
c=$(awk '{if(NR==5)print$3}' run-"$l"/XPARM.XDS)
d=$(awk '{if(NR==6)print$1}' run-"$l"/XPARM.XDS)
e=$(awk '{if(NR==6)print$2}' run-"$l"/XPARM.XDS)
f=$(awk '{if(NR==6)print$3}' run-"$l"/XPARM.XDS)
g=$(awk '{if(NR==7)print$1}' run-"$l"/XPARM.XDS)
h=$(awk '{if(NR==7)print$2}' run-"$l"/XPARM.XDS)
i=$(awk '{if(NR==7)print$3}' run-"$l"/XPARM.XDS)
a=$(echo "$a*$p/180" | bc -l)
b=$(echo "$b*$p/180" | bc -l)
c=$(echo "$c*$p/180" | bc -l)
d=$(echo "$d*$p/180" | bc -l)
e=$(echo "$e*$p/180" | bc -l)
f=$(echo "$f*$p/180" | bc -l)
g=$(echo "$g*$p/180" | bc -l)
h=$(echo "$h*$p/180" | bc -l)
i=$(echo "$i*$p/180" | bc -l)
echo 'ro=['$a','$b','$c';'$d','$e','$f';'$g','$h','$i'];
e=rotro2eu(m,ro);
save(\'euler.txt\',\'e\',\'-ascii\',\'-append\')' >> 1.txt <<EOF
EOF
let l=l+1
done
