Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

check last line in file

RobeenMar 8 2018 — edited Mar 22 2018

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

This post has been answered by Dude! on Mar 9 2018
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 19 2018
Added on Mar 8 2018
12 comments
449 views