Computing.Net > Forums > Unix > shell script for comparing file

shell script for comparing file

Reply to Message Icon

Original Message
Name: sureshht
Date: February 2, 2007 at 12:28:05 Pacific
Subject: shell script for comparing file
OS: AIX 5L
CPU/Ram: 4CPU/8GB RAM
Model/Manufacturer: IBM RS6000
Comment:

Hi,

I have a complex shell scripting requirement.

1. I need to fetch last 7 days archived log files by querying database.

2.Then I have to compare the file names i got from querying oracle table with the file name existing in the file system directory. If anything is missing i need to send mail to DBA team.

3. If everything is fine. I need to send the count of files that are archieved for the past 7 days.

4. I will have to schedule it to run on monday morning so that I can report the summary for the last week.

I can fetch list of file names from oracle tables and put it in a temp file. but i am wondering how to compare this list with list of file system files. I need to compare with the name of the file.

If you need more details, let me know
Can anyone help me?

Thanks and regards
Suresh H Thopaiah
sureshht@yahoo.com


Report Offensive Message For Removal

Response Number 1
Name: thepubba1
Date: February 2, 2007 at 18:09:56 Pacific
Subject: shell script for comparing file
Reply: (edit)

OK. Given a sample file that looks like this:

Input file name "files.in"
cygwin.tic
dhcp.ksh
gethost.exe
junk.html
junk1.html
junk3.html
keys.txt
license.txt
misc.txt
numbers.txt
output.lines
trchkid.h
united.txt

And I want to find out if these files exist in the /home/Administrator directory, I'd do this:

#!/bin/ksh

Directory=/home/Administrator

exec 3<files.in

while read -u3 filename
do
if [[ -f $Directory/$filename ]]
then
print "File found"
else
print "File not found"
fi
done



Report Offensive Follow Up For Removal

Response Number 2
Name: sureshht
Date: February 5, 2007 at 10:53:45 Pacific
Subject: shell script for comparing file
Reply: (edit)

Hi,

Thanks for your reply.
I am pulling list of archivelog files from database to a tempfile1.

Also I am pulling directory archivelog path from database and putting in tempfile2.

I want to go to the directory path (cd to) in the tempfile2. say tempfile2 has the path '/oracle/app/oracle/admin/sepmbx1/archive'. I want to go to this path and pump the list of files in the directory to a tempfile3.

Then I want to compare the existance of entries from tempfile1 in the tempfile2.

I dont know whether i am clear on what I want. Please let me know if any confusion

Thanks and regards
Suresh


sureshht


Report Offensive Follow Up For Removal

Response Number 3
Name: thepubba1
Date: February 6, 2007 at 08:18:33 Pacific
Subject: shell script for comparing file
Reply: (edit)

Got several issues you need to resolve. Do the file names extracted from the database have a relative or absolute path?

If they have an absolute path, they should have the form:

/mydir/filename

and if they have an relative path then they'll have the form:

./mydir/filename

and finally, do they contain just a file name such as

myfile

Let me know and I'll cook something up for you.


Report Offensive Follow Up For Removal

Response Number 4
Name: sureshht
Date: February 12, 2007 at 12:58:08 Pacific
Subject: shell script for comparing file
Reply: (edit)

I solved my issue with another one i filed:
'comparing 2 files with shell script' in this forum.

Thanks for your assistance.

Suresh


sureshht


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: shell script for comparing file 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software