Red Hat Linux 6
Hi,
I want to write a bash script to to check if last line in a file is equal to "Import dump completed successfully".
The condtion is if "Import dump completed successfully" is not present in logfile, error will be written to a variable in another file(output.properties)
cd /oldbackup/DNRTOOL/cidev/exportlog
arch1=$(ls -t | head -1)
cd /oldbackup/DNRTOOL/gaiadev/exportlog
arch2=$(ls -t | head -1)
cd /oldbackup/DNRTOOL/gcidev/exportlog
arch3=$(ls -t | head -1)
if [ $(\grep "IMP-00000: Import terminated successfully" $arch1 ] <--- to check
then
sed -i 's/^IMPORTGAIAGCICIFLAG.*/IMPORTGAIAGCICIFLAG=ERROR IN CI/g' /comptel/output.properties
if [ $(\grep "IMP-00000: Import terminated successfully" $arch2 ] <--- to check
then
sed -i 's/^IMPORTGAIAGCICIFLAG.*/IMPORTGAIAGCICIFLAG=ERROR IN GAIA/g' /comptel/output.properties
if [ $(\grep "IMP-00000: Import terminated successfully" $arch3 ] <--- to check
then
sed -i 's/^IMPORTGAIAGCICIFLAG.*/IMPORTGAIAGCICIFLAG=ERROR IN GCI/g' /comptel/output.properties
fi
fi
fi
Can anyone please guide me for the if statement, if "IMP-00000: Import terminated successfully" is not present in $arch1 or $arch2 or $arch3, then output the ERROR message in /comptel/output.properties
Thanks,
Joe