make a list based on the first column key and corresponding value (2nd column-bold) in input1 search values that less than or equal to 1000 (2nd column-bold)in the input2 of the same key along with other columns.
The input1 contain keys in first column (x1,x2 and so on). second column contains values ranging from smaller to largest (1 to 10000000 and so on).Second input is also the same.
Logic is to find the values that are with in +/-1000 with corresponding to values in input1 (along with corresponding columns not shown below)
As you can see below the ist input value is 10000 (the values with in range of +/- 1000 i.e. +1000=11000 and -1000=9000 are in output others are not)
repinementer, you have 150++ posts, i am sure you are already competent enough to start showing some of your own code. what have you tried? search back your previous posts and see how awk is used to solve some of your other similar problems.
x1 10 x1 800 [x1 10+/-1000=1010 or -990 i.e all the values bw 1010 and -990 with a similar key x1 those are 800,900,1010 ]
x1 10 x1 900
x1 10 x1 1010 [x1 100+/-1000=1100 or -900 i.e all the values bw 1100 and -900 with a similar key x1 those are 800,900,1010,1100 ]
x1 100 x1 1100
x1 100 x1 800
x1 100 x1 900
x1 100 x1 1010
x2 1000 x2 2000 [x2 1000+/-1000=2000 or 0 i.e all the values bw 2000 and 0 with a similar key x2 those are 2000 ]
x2 10000 NULL NULL [Have none]
x3 989 x3 1989 [x3 989+/-1000=1989 or -11 i.e all the values bw 1989 and -11 with a similar key x3 those are 1989]
x4 345 x4 1345 [x4 345+/-1000=1345 or -665 i.e all the values bw 1345 and -665 with a similar key x4 those are 1345]
x10 8767736477736 x10 8767736478730 [same like above]
xx 234 xx 1234 [same like above]
xy 387889999 xy 387888999 [same like above]
---------- Post updated at 07:38 PM ---------- Previous update was at 06:22 AM ----------
---------- Post updated at 07:43 PM ---------- Previous update was at 07:38 PM ----------
and it would be grateful if you suggest how to define other columns in the same script like a[$1]=$1 .....so that i can print all the other column along with the output
Hi.Thanx for explaining array definition by using a,b and c. Very helpful. The result for your code ouput is as almost same as mine. The bold letters in desired output below I high lighted are missing.? Do you know why?
Still the same error.
Anyways with out it (\)the script working great. Thank you.
Still I have not cleared the doubts about previous scripts(awk one liners). Whats wrong with the previous scripts?
Using the first column value as array key to hold the second column value, because you have multiple records having the same key value (x1 and x2 in this example) each one will overwrite the previous one and only the last one will be saved in array as per your example: