I need to check numbers in each line on a specific column in one variable against all lines in two specific columns in another variable using awk
, keeping lines in the first variable that meet parameters.
Attempts I have made so far to do this in one powerful awk
command have failed. I can obviously do this in an external loop, but it would be very slow as I have 100's of thousands of lines to check. I appreciate any and all help with solving this, and I am always looking to improve my use of awk, so if you have a solution it would be great to have an explanation so I can learn and improve myself.
Here is an example:
Lets say I want to print only the lines in column 2 from
${ListToCheckFrom}
, if the number there is > column 2 and < column 3 in any line from${ListToCheckAgainst}
Input example:
ListToCheckFrom="C,2 C,22 C,12 hr,15" ListToCheckAgainst="C1,25,50 hr1,22,30 r,12,18 C,15,44"
Expected output:
C,22 hr,15