Aveek,
You can use the diff utility and redirection for this, though I don't know
what you're doing with the output so I don't know if it would be any better,
but....
setvar NUMRECS;finfo("filea",19)+finfo("fileb",19)
setvar RECSIZEA;finfo("filea",14)
setvar RECSIZEB;finfo("fileb",14)
if !RECSIZEA < 0 and !RECSIZEB < 0
# both files are in bytes
if !RECSIZEA <= !RECSIZEB
setvar RECSIZE !RECSIZEA
else
setvar RECSIZE !RECSIZEB
endif
else
# one or both files are in words
if !RECSIZEA > !RECSIZEB
setvar RECSIZE !RECSIZEA
else
setvar RECSIZE !RECSIZEB
endif
endif
build outfile;dev=disc;disc=!NUMRECS;rec=!RECSIZE
file out=outfile,old;acc=append
run diff.util.sys;info="FILEA FILEB" >>*out
------------------The output in "outfile" will look like:
8c8
< !PURGE DPSDFTMP
---
> !bob PURGE DPSDFTMP
22c22
< !COMMENT
---
> !bob COMMENT
-----------------To limit the output further you would need to "clean"
outfile.
build outfile2;dev=disc;disc=!NUMRECS;rec=!RECSIZE
file output2=outfile2,old;acc=append
build outtemp;dev=disc;disc=!NUMRECS;rec=!RECSIZE;TEMP;MSG
file outtemp=outtemp,oldtemp
print outfile >*outtemp
while finfo("*outtemp",19) > 0
input onerec <<*outtemp
setvar char1;str("!onerec",1,1)
if "!char1" = "<" or "!char1" = ">"
echo !onerec >>*output2
endif
endwhile
---------------This will leave you with output similar to:
print outfile2
< !PURGE DPSDFTMP
> !bob PURGE DPSDFTMP
< !COMMENT
> !bob COMMENT
------------where the "<" means the record is in FILEA and ">" means FILEB.
Will this do what you need?
Rs~
Russ Smith, Systems Consultant
Problem Solved, Vacaville, CA
r s m i t h @ c u - h e l p . c o m
h p 3 k - l @ e - 3 0 0 0 . n e t
----- Original Message -----
From: <[log in to unmask]>
To: <[log in to unmask]>
Sent: Monday, September 25, 2000 7:27 PM
Subject: [HP3000-L] compare to files
> hi all,
> I have two file of similar structure and content, I want to
compare both
> the file and pass the rows that are different from one of the file onto a
third
> file.
> How do you do that ? I tried
> file filea=partin
> file fileb=partout
> file outfile=diff
> Run COMPARE.PUB.ROBELLE;INFO="F1"
>
> and got the following output
> ----------------------------------------
> Mismatch:
>
> Line 378 of PARTIN.WWCLASS.PPMDMFG:
>
> > 8471801000 5065-0428
>
> Line 378 of PARTOUT.WWCLASS.PPMDMFG:
>
> > 8471801000 5065-0428
>
> ----------------------------------------
> Mismatch:
>
> Line 454 of PARTIN.WWCLASS.PPMDMFG:
>
> > 8473301000 5184-3230
>
> Line 454 of PARTOUT.WWCLASS.PPMDMFG:
>
> > 8473301000 5184-3230
> (24/114) Continue?
>
> ----------------------------------------
> Mismatch:
>
> Line 504 of PARTIN.WWCLASS.PPMDMFG:
>
> > 8471706000 C1555-60003
>
> Line 504 of PARTOUT.WWCLASS.PPMDMFG:
>
> > 8471706000 C1555-60003
>
> But I just want the rows nothing else, some times it is better to
have
> less descriptive things.
>
> Thanks in advance.
>
> Aveek
>
|