I know the topic sounds familiar but I just couldn't adapt or find the right code that solves my particular issue. I really hope you can help.
I would like to compare 2 files in an awk script. Both files have different paths.
The awk script call should look like that awk -f AWKSCRIPT parameter1.
The files look as follows:
File_old
Header
record1
record2
record3
Footer
File_new
Header
record1
record2
record3
Footer
First I would like to test if both files have the same amount of records.
If NO, return a code("NOMATCH") that can be further processed by a shell script. AWK Script is supposed to be called from within a bourne shell script.
If YES, please compare just the records Line by Line. I mean compare:
File_old:record1 with File_new:record1
File_old:record2 with File_new:record2
and so on...
If one of those comparisons doesn't match, return again a code("NOMATCH") that can be further processed by the calling bourne shell script. If all of the records match with on another return code("MATCH") to calling bourne shell script.
Sorry I am crazy busy right now. I would have liked to reply much earlier already. But as the title is mentioning I am busy like hell. Thanks for your help, I will try it out and let you guys know what happend.
Thanks again guys for your response, but the files I would like to compare have something special to it.
Like I already mentioned, both files have the same layout:
Header
Record1
Record2
...
Footer
The header is always different, so nothing to be focused on.
The records first 25 signs are always different too.
Now the important part. After sign 25 of each record I would like to start comparing with the corresponding record in the second file.
if record1.file1 after sign25 equals record1.file2 after sign25
set return value 0
else set return value 1
and so on for all remaining records.
Note: I can't do anything about the format of the file. I get it that why and I have to work with it.