Compare 2 flat files

Hi Gurus,

I searched the forum but didnt get much info.
I want to compare 2 files.

1)Newfile comes today with
2)Old file of previous day.

The files are same ,just the new files might have new records sometimes.

So I want to capture these new records in another file.

Can anyone help me in this ??

Thanks

If all you just want is a file containing the differences between your old and new files then try:

diff old_file new_file > diff_file

lines only in new_file will be preceded by >

thanks for reply but I guess using diff will also give the records which are present in old file and not in new file.

I just want to capture the records not present in old file and present in new file.

The following should work:

diff old_file new_file | grep ">" | cut -b 3- > new_records.txt

grep entries that are in the newer file only, and cut the first two leading chars that diff outputs.

Records that are in the old file only will not be in the new one.

If you are on solaris, you can use:

/usr/xpg4/bin/grep -v -f oldfile newfile > diff_file

Thankyou everybody for your precious time.