Validating the file

Hello All,

I have the following file. The first column is Type. Always the file will have one H and one T type in between all D type reocrds.
Need todo some validations.

 
H|ABCD
D|TAB N0003107809CD2013-11-14|RYAN|FRY|7 DR|RICHMOND HILL|GA|32431|X|C95|000009999|000000001|TAB||C0001
D|TAB N0004251713CD2013-11-14|JOHN|Mc|3 DR|MAYS LANDING|NJ|33058|Y|C95|000009999|000000001|TAB||C0001
D|TAC N0002375248CD2013-11-14|MICHAEL|Clarid|3 RD|MOUNT SINAI|NY|76611|F|C95|000009999|000000001|TAC||C0001
D|TAC N0006321198CD2013-11-14|John|MILLER|44 RD|BASTROP|LA|65220|G|C95|000009999|000000001|TAC||C0001
D|TAC N0009983305CD2013-11-14|PAUL|Jame|40 DR NW|GRAND RAPIDS|M|94534|X|C95|000009999|000000001|TAC||C0001
T|C95|000009999|000000001|5

Validations:

  1. Number of "D" type records should be same as count mentioned in 5th field of "T" type record.
  2. 10, 11 & 12 fileds should be same in all "D" type records and match with "T" type record of 2, 3 and 4 fileds respectively.

Thanks in Advance!

With over 100 posts in these forums, we hope that your have been learning from us. What have you tried so far?

yah I tried first validation by using awk and if condition.
second one I tried but not successful.

Show us your code. And, show us your desired output (both for successful validation and failed validations!