1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #!/bin/bash
# give x.gro as first command line arguement
upperz=8.0
lowerz=4.8
sol=SOL
count=0
cat $1 | grep "$sol" | while read line; do
for first in $line; do
break
done
if [ "$count" = 3 ]; then
count=0
fi
count=$(expr $count + 1)
if [ "$count" != 1 ]; then
continue
fi
l=${#line}
m=$(expr $l - 24) # would use -48 if velocities are also in .gro and -24 otherwise
i=1
for word in ${line:$m}; do
if [ "$i" = 1 ]; then
popex=$word
else
if [ "$i" = 2 ]; then
popey=$word
else
if [ "$i" = 3 ]; then
popez=$word
break
fi
fi
fi
i=$(expr $i + 1)
done
nolx=`echo "$popez > $upperz" | bc`
nohx=`echo "$popez < $lowerz" | bc`
myno=$(expr $nolx + $nohx)
if [ "$myno" != 0 ]; then
z=${#first}
if [ "$z" != 8 ]; then
sfirst="[[:space:]]$first"
else
sfirst=$first
fi
`echo grep $sfirst $1`
fi
done |
Partager