Hello everyone, I need help with another script.
So, I have a bunch of files called trace_checker_b00, trace_checker_b01, etc…
These files look something like this:
rec_id comptype seqno id_check
11111111 1 872131 0.00
11111111 2 872131 0.00
11111111 3 872131 0.00
11111111 4 872131 0.00
22222222 1 862315 0.00
22222222 2 862315 0.00
22222222 3 862315 0.00
22222222 4 862315 0.00
33333333 1 872131 0.00
33333333 2 872131 0.00
33333333 3 852999 0.00
33333333 4 840001 0.00
....
and so on.
I’m trying to write a script that will go through and check two things.
-
id_check is always equal to 0.00. If it’s not, I want the script to spit out the corresponding rec_id that does not have id_check = 0;
-
I want it to go through each rec_id and make sure that the seqno values are all the same for each comptype per rec_id. So in the example given above, rec_id 11111111 and 22222222 are fine because the seqno values are all the same for each comptype, but rec_id 33333333 does not have the same seqno values for each comptype. If all 4 comptypes do not have the same value for seqno, I want the script to spit out the rec_id value with mismatching seqno values.
Now, a couple of things. The program that generates these text files does not tab delimit them. The fields are separated by spaces and there is no way to change this. I believe this makes a difference in how the fields can be read in.
I believe this could be handled simply with awk but I’m not very good with bash scripting period, let alone awk which always boggles my mind.
I know that basically I need to do a for loop that will loop through all files matching trace_checker*.
I know that with the awk command I have 4 fields, $1=rec_id, $2=comptype, $3=seqno, $4=id_check.
But I’m lost on exactly what to do with it all. Because predictably there are ALWAYS 4 comptypes, it makes it a little easier to do the checking, but I’m not sure of how to check that all the seqno values are the same for a given rec_id.
Any help is appreciated, and thank you in advance!