script to match statement from a file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script to match statement from a file
# 1  
Old 08-19-2011
script to match statement from a file


I am trying to write a script which will match the statement from one log file and then proceed for other commands mention in the script.

for my application, backup is schedule to run every day at particular time and creats a log file "/var/adm/backuplog".
if backup completes then last line of this log file will be as below if backup completes on 19th aug
"08/19/2011 11:57:53 Backup has been completed."

this log file is incrimental file, so we can find "Backup has been completed" statement multiple times but with 19th date only one.

Now I want to write a script to check backup completed or not and my require file has been backedup or not. this script will match the last line with current date from the backuplog file. if this script finds that last line says "Backup has been completed" with current date then it will proceed further to check other commands or it will send mail saying that "Either backup has been failed or it is still running"

Could any one please help me, how to write this script?

# 2  
Old 08-19-2011
I'm confused. Wouldn't it be better to make the backup system not say "backup completed" if it didn't actually complete?
# 3  
Old 08-20-2011
Actually there are lots of file which is schedule to be backedup through backup script. backup script is written in suhch manner that if any any file is being used or open then backup script will escape that file and will move for another file. if backup script touches all the files then in log file at last line we can find entry "backup has been completed" and those file which has not been backedup we can find one entry "not backedup" or "aborted".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

if then else; no variable match but statement executes anyway.

My first then statement is executing even though there is no match between the variables. each subsequent if then statement is also executing. Why do they execute when there is no match in the dates? yr=`date +%y` date1=12-31-$yr date=`date +%m-%d-%y` set -vx if ; ... (6 Replies)
Discussion started by: bash_in_my_head
6 Replies

2. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

3. Shell Programming and Scripting

Bash Script Issues (If statement for file copying)

Writing a bash script for use with Geektool, pulls the battery info, and shuffles images around so that an Image geeklet can display the correct expression as the desktop background. (Eventually I intend to make it more intricate, based on more variables, and add more expressions) I'm extremely... (1 Reply)
Discussion started by: The_Ardly374
1 Replies

4. Shell Programming and Scripting

trying to find match from multiple string if statement

I'm trying to create what (should be) a simple bash script that will pull computer name and use that info to bind to one of three servers. Is there any way to do this without having a text file with the names of the servers and associated computer names? (5 Replies)
Discussion started by: jacobsbigbro1
5 Replies

5. Shell Programming and Scripting

awk pattern match and search in single statement

Hi All, I am trying to alter all lines between EXEC SQL and END-EXEC that have an INCLUDE in them. The following code search="INCLUDE " cp -f ${WORK}/$ ${WORK}/$file.wrk2 for item in `echo $search `; do > ${WORK}/$file.wrk1 awk -vITEM="$item" '{ if ( $0... (3 Replies)
Discussion started by: Bruble
3 Replies

6. Shell Programming and Scripting

simplify the script, check field match to value in a file

Hi Everyone, Below is the script, i feel there should be more simple way to do the same output, my one works, but feel not nice. like using index i feel it is slow (image my file is very large), maybe awk can do one line code? Please advice. # cat 1.txt 1 a 2 b 3 cc 4 d # cat (6 Replies)
Discussion started by: jimmy_y
6 Replies

7. Shell Programming and Scripting

Match File and Copy File Script (Homework, Closed)

Can you please help on this? I am looking for the shell script which does following:- step 1: It should open the file /u/manish/input/FileIndex.dat and read line by line step 2: Once first line is read (for ex: File1), we have to find a file, that contains this matching... (4 Replies)
Discussion started by: teteguru1
4 Replies

8. Shell Programming and Scripting

How to match the last XML extension by using Case statement

Hi All, I have a status.txt file which contains following three files. 1.xml 2.xml 3.xml Now i have written a shell script which contains the following cat status.txt | while read filename do echo $filename case "$filename" in xml) echo "running 1.xml" ;; ... (3 Replies)
Discussion started by: sunitachoudhury
3 Replies

9. UNIX for Dummies Questions & Answers

Regex in if-then-else statement to match strings

hello I want to do a pattern match for string in the if statement, but I am not sure how to use regex inside the if statement. I am looking for something like this: if {2,3} ]; then ..... .... ... fi (7 Replies)
Discussion started by: rakeshou
7 Replies

10. UNIX for Dummies Questions & Answers

if statement to match *

Hi I have a script like read i if then echo bingo fi I want to enter the if block if i is equal to * The same doesn't happen , when I input * the script fails with error "[: too many arguments" I know it is very basic , but still Could any one help me out with the issue ... (3 Replies)
Discussion started by: sivasenthil_k
3 Replies
Login or Register to Ask a Question