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.