Need help in file validation by shell script

Hi
I am new to this forum.I need a help in the following:
We receve pipe delimited file with
transaction ID,tran_date,Quest_cd,Ans_cd,ans_value.
Same transaction ID can be repeated with different quest_cd and ans_cd.

Basically I need to check if a perticular pair of quest_cd and ans_cd (say Q1234,A1234) is present under a transaction ,then another pair of quest_cd and ans_cd (say Q5678,A5678) should also be present.

Otherwise I need to remove the isolated row from input file and write to a bad file which should have the complete row in defect and with a comment that Q1234A1234 present but Q5678A5678 not present Or vice versa.

The balance good records sholud be written to a good file.

I hope I am clear in my explanation.As this is VERY urgent I appreciate immediate help
Regards
SRK

Please read the rules of the forum

Please don't cross post.

Here is the thread for which I had replied.

http://www.unix.com/unix-for-dummies-question-and-answers/40377-need-help-in-unix-shell-script.html

Moderators please :slight_smile: