Compare script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compare script
# 1  
Old 01-08-2010
Compare script

I have 8 set of files.

eg:
File 1 -- sybase row count
emp 45
dept 55
outln 78
xxx 91

File 2 -- oracle row count
emp 71
dept 10
outln 78
xxx 91
rtyurtuyrtuyrt 123
ghdfghdfghgh 6578

We have to compare such files get the difference and send output via mailx. See the program below it shows output like
next_number -1
v_man 5

I want to also display the text which is present in file 1 and not in file 2.
Alos display should have heading as -
Table _name oracle_count sybase_count Diff
Could you alter my prog or give a better prog.

#!/bin/ksh
DBALIST='abc@xyz.com'
SUBJECT="WARNING: xxx"
flag='N'
while read a1 a2
do
echo $a1
flag='N'
while read b1 b2
do
if [ $a1 = $b1 ]
then
flag='Y'
if [ $a2 = $b2 ]
then
echo matching
elif [ $a2 != $b2 ]
then
dif=`expr $a2 - $b2`
echo $a1 $dif >> diff.out
fi

fi
done < oracle.sql
if [ $flag = 'N' ]
then
echo $a1 $a2 >> diff_master.out
fi
done < sybase.sql
mailx -s "$SUBJECT" $DBALIST < test.out


-------
Add the following header as first line in each email report:
Table_Name Sybase_RowCount Oracle_RowCnt Diff
Script needs comments and indenting to make it more readable. Indenting needed to visually see the if/elif/fi blocks and do blocks. Script does not capture any information if table exists in Sybase and not in Oracle or viceversa
If script finds no differences for any schema, still should get email indicating no differences for that schema.
# 2  
Old 01-08-2010
Quote:
Originally Posted by noorm
-------
Add the following header as first line in each email report:
Table_Name Sybase_RowCount Oracle_RowCnt Diff
Script needs comments and indenting to make it more readable. Indenting needed to visually see the if/elif/fi blocks and do blocks. Script does not capture any information if table exists in Sybase and not in Oracle or viceversa
If script finds no differences for any schema, still should get email indicating no differences for that schema.
I dont understand this part of your post.
# 3  
Old 01-08-2010
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need script to compare and redirect

Hi, I have a file, sol_servers_global, which is list of all solaris global servers in my environment and another file, solaris_non_global_zones_from_DB. I have a gateway server, from where all servers are contactable via ssh. I have collected name of zones running on these servers with below... (3 Replies)
Discussion started by: solaris_1977
3 Replies

2. Shell Programming and Scripting

Script to compare two text files

i am working on a shell script and need help in the comparing part of it. for e.g. there two text files like this: file1.txt name1 name2 name3 file1 has to be comared with file2 defaultfile.txt name1 name2 name3 name4 and during comparision with defaultfile.txt if... (2 Replies)
Discussion started by: draghun9
2 Replies

3. Shell Programming and Scripting

Script to compare 1 file with all others

I need a script to compare 1 file with all others then print off any new lines which the other files do not have. Running: Solaris 10 5/09 s10s_u7wos_08 SPARC Any help or pointers would be appreciated (26 Replies)
Discussion started by: llcooljatt
26 Replies

4. Shell Programming and Scripting

Date Compare Script

Hi All, I wil be having Files as below in SourceFile_Path DIR AA.20110131 AA.20110228 AA.20110202 AA.20110330 BB.20091031 I want to Keep only monthly (20110131,20110228,20100229,20110330) in First SourceFile_Path, If it is not monthly file then want to Move files to some another... (5 Replies)
Discussion started by: samadhanpatil
5 Replies

5. Shell Programming and Scripting

Script to compare binaries

Hi All, I am very new to scripting and wanted to write a script for comparison of folder including binary files like ear's and jars. Following is the job for which I need it: 1. Compare two folders recursively 2. Compare the binaries like ear's but exclude files like MANIFEST files 3.... (1 Reply)
Discussion started by: maverick.topgun
1 Replies

6. UNIX Desktop Questions & Answers

Script to compare md5

From couple of hours i try to do a script to compare file MD5. Help would be very appreciated :) First i read the md5 stored into a text file (no problem): md5=`grep -P "^{32}" $file` then i want to calculate the checksum and store it : cmd5=`md5sum licence.gvcl` then problems arrives, i... (5 Replies)
Discussion started by: giova
5 Replies

7. Shell Programming and Scripting

Script to compare lines

I need a simple script to parse a file with this data in it and have that script output a warning when CurrCapacity is more that 50% of MaxCapacity for a given pool Name, can anyone help ? CurrCapacity: 5 MaxCapacity: 20 Name: fhlwDSource CurrCapacity: 5 ... (3 Replies)
Discussion started by: init0
3 Replies

8. Shell Programming and Scripting

Directory compare script

Hello, I am looking for a script, or pointer to an approach to creating a script, that will compare two versions of a codebase and output a third directory structure containing only the files that differ between the two. I use diff quite often, but it will only create patch files (AFAIK). Does... (3 Replies)
Discussion started by: jwilliams108
3 Replies

9. Shell Programming and Scripting

script to compare files

HI i wil get input from sql query and that too i can get a list o f files or just one. i have to pick up a file from another directory which hads prefix to this prefix.x.x.x.x.x. And we have to discard prefix and use that file name. we have to compare this file name(no need... (0 Replies)
Discussion started by: pulse2india
0 Replies
Login or Register to Ask a Question