[HPADM] SUMMARY: Comparing the file on record level

From: Lal, Neeraj (Neeraj.Lal@Pfizer.com)
Date: Tue Oct 29 2002 - 13:44:00 EST


Hi

Sorry for replying late.....
Actually nobody had given the exact solution what i wanted it. But I solved
it on my own after reading the man of diff
here is the small script

diff -c file-a file-b > temp
grep "^!" temp > recchgfilea-b.data
grep "^+" temp > recextrafilea.data
grep "^- " temp > recextrafileb.data
grep "^ " temp > recsamefilea-b.data
sort recchgfilea-b.data > recchgfilea-b.txt
sort recextrafilea.data > recextrafilea.txt
sort recextrafileb.data > recextrafileb.txt
sort recsamefilea-b.data > recsamefilea-b.txt
rm *.data

file -a (contents)
$ 0.39 -- Package of Groat Clusters
$ 5.00 -- Candy Apple Sampler Pack
$ 12.00 -- Box of Crunchy Frog Chocolates
$ 15.99 -- Instant Rain (Just Add Water)
$ 20.00 -- Asparagus Firmness Meter
$ 25.00 -- Package of Seeds for 35 Herbs
$ 30.00 -- Child's Riding Hood (Red)
$ 35.00 -- Genuine Placebos
$ 45.00 -- Case of Simulated Soy Bean Oil
$ 75.88 -- No-Name Contact Lenses
$ 99.99 -- Kiddie Destructo-Bot
$125.00 -- Emperor's New Clothes

file-b (contents)
$ 0.39 -- Package of Groat Clusters
$ 5.49 -- Candy Apple Sampler Pack
$ 12.00 -- Box of Crunchy Frog Chocolates
$ 15.99 -- Instant Rain (Just Add Water)
$ 17.00 -- Simulated Naugahyde Cleaner
$ 20.00 -- Asparagus Firmness Meter
$ 25.00 -- Package of Seeds for 35 Herbs
$ 30.00 -- Child's Riding Hood (Red)
$ 35.00 -- Genuine Placebos
$ 45.00 -- Case of Simulated Soy Bean Oil
$ 75.88 -- No-Name Contact Lenses
$ 99.99 -- Kiddie Destructo-Bot

temp (content)which is intermediate output
*** price1 Wed Mar 04 10:08:40 1992
--- price2 Wed Mar 04 10:09:10 1992
***************
*** 1,9 ****
  Company X Price List:
  $ 0.39 -- Package of Groat Clusters
! $ 5.00 -- Candy Apple Sampler Pack
  $ 12.00 -- Box of Crunchy Frog Chocolates
  $ 15.99 -- Instant Rain (Just Add Water)
  $ 20.00 -- Asparagus Firmness Meter
  $ 25.00 -- Package of Seeds for 35 Herbs
  $ 30.00 -- Child's Riding Hood (Red)
--- 1,10 ----
  Company X Price List:
  $ 0.39 -- Package of Groat Clusters
! $ 5.49 -- Candy Apple Sampler Pack
  $ 12.00 -- Box of Crunchy Frog Chocolates
  $ 15.99 -- Instant Rain (Just Add Water)
+ $ 17.00 -- Simulated Naugahyde cleaner
  $ 20.00 -- Asparagus Firmness Meter
  $ 25.00 -- Package of Seeds for 35 Herbs
  $ 30.00 -- Child's Riding Hood (Red)
***************
*** 11,14 ****
  $ 45.00 -- Case of Simulated Soy Bean Oil
  $ 75.88 -- No-Name Contact Lenses
  $ 99.99 -- Kiddie Destructo-Bot
- $125.00 -- Emperor's New Clothes
--- 12,14 ----

and finally I grep as per the first sign in the column which means

One line was changed in both files (marked with !)
One line was added to price1 (marked with +)
One line was removed from price1 (marked with -).

and sorted the file
Thanks

-----Original Message-----
From: John Backus [mailto:john@beechglen.com]
Sent: Tuesday, October 29, 2002 12:52 PM
To: Lal, Neeraj
Subject: Re: [HPADM] Comparing the file on record level

Lal,

How did you finally solve this?

I never did see your summary post back to the list.

John Backus
beechglen.com
(513) 922-0509

----- Original Message -----
From: "Lal, Neeraj" <Neeraj.Lal@Pfizer.com>
To: <hpux-admin@DutchWorks.nl>
Sent: Wednesday, October 23, 2002 3:53 PM
Subject: [HPADM] Comparing the file on record level

> Hi Admins
>
> I have a script question to basically compare the flat files records. The
> scenario is like this
>
> I have 2 Files
>
> FILE A & FILE B
>
> I have to read FILE A record no 1 and search the file B is there any
> matching record if yes write that record to FILE C else write FILE D
>
> Thanks
> Neeraj Lal
>
>
> Neeraj Lal,
> Consultant
> p Consumer Healthcare IS
> Neeraj.Lal@Pfizer.com
> Fax : 973-385-7290
>
>
>
> --
> ---> Please post QUESTIONS and SUMMARIES only!! <---
> To subscribe/unsubscribe to this list, contact
majordomo@dutchworks.nl
> Name: hpux-admin@dutchworks.nl Owner:
owner-hpux-admin@dutchworks.nl
>
> Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse
only)
> http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse &
search)
>

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:21 EDT