Operating System - HP-UX
1835626 Members
3631 Online
110081 Solutions
New Discussion

Need to Compare the two extacts

 
reddykumar
Occasional Contributor

Need to Compare the two extacts

Hi

 

I need a shell script or perl script, Basically it needs to accepts two extract paths as inputs and comapre the two ouptputs (apple to apple) , Just we need to ensure that the extracts have the correct format and the content is also matching .

 

In Comparsion one would be  the baseline ( assume to be correct ) and other is new extract generated.. We just to need do some comaprions and give the output saying it is matching or not matching with the difference report..

 

Note: The file delimeter separted is "|"

 

Kinldy help me in designing the test script for this

 

Thanks for your time & highly appreciated

 

Reddy

4 REPLIES 4
Patrick Wallek
Honored Contributor

Re: Need to Compare the two extacts

Have you looked at the 'diff' command?

reddykumar
Occasional Contributor

Re: Need to Compare the two extacts

Please can you help me in designing the shell script for this, accepting two paramters ... and checking the File headers and the Data content, if everything is macthing saying... "All the records are amcvthing" or else need to give the the rows where it is not matching

 

Thanks for your help much appreciated!

 

Steven Schweda
Honored Contributor

Re: Need to Compare the two extacts

> Please can you help me [...]

   Probably not, unless you can explain exactly what you're trying to
do.

   My psychic powers are too weak to tell me what you mean by:
      The file delimeter separted is "|"
      File headers
      Data content

We non-psychics can't see your files, and probably can't guess exactly
what you wish to do with them.

   Still a good idea:
      man diff

If "diff" does not do what you want, then you might try (again?) to
explain exactly what you do want.

Dennis Handly
Acclaimed Contributor

Re: Need to Compare the two extracts

>can you help me in designing the shell script for this, accepting two parameters

 

As Patrick mentioned, look at diff(1).

 

If these two files are text files, you can do:

#!/usr/bin/sh

# Usage: $0 file1 file2

diff $1 $2

if [ $? -eq 0 ]; then

   echo "All the records are matching"

fi

 

The above scripts assumes the names of the files aren't in the files, which would be a difference to ignore.