Script to find difference between 2 files by column

Hi , i am newbie to shell scripting and am trying to do the below job,

A shell script to be run with a command like

sh Compare.ksh file1.txt file2.txt 1 2 > file3.txt

1 2-are the key columns
Consider the delimiter would be Tab or comma

File 1:

SK TEST NAME MATHS PHYSICS
21 1 AAA 45 65
21 2 AAA 48 66
22 1 BBB 46 64
22 2 BBB 47 65
23 1 CCC 58 85
23 2 CCC 59 88

File 2:

SK TEST NAME MATHS PHYSICS
21 1 AAA 45 65
21 2 AAA 48 66
22 1 BBB 46 6
22 2 BBB 47 65
23 1 CCC 58 85
23 2 CC 59 88
And return result like,

File 3:

FILE SK TEST NAME PHYSICS
file1.txt 22 1 BBB 64
file2.txt 22 1 BBB 6
file1.txt 23 2 CCC
file2.txt 23 2 CC

Any expert help for this student? :slight_smile:

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.