#! /bin/bash
# Moves to another directory all SMILES containing an oxygen atom which
# appears not to be divalent. These SMILES should be checked, 
# in many cases, they are coordination compounds with correct brackets around
# the oxygen.

[ -d ../working ] || mkdir ../working
for i in `ls *.smi` ; do
   radical=no
   dato=`cat $i | grep [[]O[]]`
   if [ "$dato" != "" ]; then
     radical=si
   else  
     dato=`cat $i | grep [[]OH[]]`
     if [ "$dato" != "" ]; then
       radical=si
     fi
   fi
   if [ "$radical" == "si" ]; then
       mv $i ../working
   fi
done
