Folks, I wish to do something like the following in a bash script but
can't work out the correct incantation of escape chars etc so any advice
welcome! ie what is it I need to do for env var STRING and the grep
command so that grep -e $STRING handles the space in STRING correctly.

Ta, Michael


#!/bin/bash -x

### script to check when STRING appears in FILE

if [[ $# -eq 0 ]]; then
            STRING=After\ NEXTIME
            FILE=UK108_N2O5aeroHet_varGamma-hybridCMU_INI.log
elif [[ $# -eq 2 ]]; then
            STRING=$1
            STRING=$2
else
    echo Usage\: $0 [string file]
    echo To loop until \$string found in \$file
    exit
fi
echo Looping until 
echo "  '${STRING}'"
echo found in $FILE

while [[ `grep -e ${STRING} ${FILE} |wc -l` -lt 1 ]];do 
    echo nope
    sleep 60
done



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to