I have to revive and old question with a modification for long files.
I have the age of two stars in two files (File1 and File2). The column of the age of the stars is $1 and the rest of the columns up to $13 are information that I need to print at the end.
I am trying to find an age in which the stars have the same age or the closest age. Since the files are too large (~25000 lines) I don't want to search in the whole array, for speed issues.
Also, they could have a big difference in number of lines (let say ~10000 in some cases)
I am not sure if this is the best way to solve the problem, but in a lack of a better one, this is my idea. (If you have a faster and more efficient method, please do it)
All the values are with 12 decimals of precision. And for now I am only concern in the first column (where the age is).
And I need different loops.
Let's use this value from file 1:
First the routine should search in file2 all the matches that contain
(This loop probably will search in the whole array, but if there is a way to stop the search as soon it reaches 2.3261 then it will save some time)
If it finds just one, then the output should be that value.
Usually, it will find several lines, maybe even up to 1000. It this is the case, it should search again against
between the lines founded before. (It is a nested loop I think)
Then the number of matches will decrease up to ~200
At that moment, the routine should search the best difference with certain tolerance X between
and all these 200 lines.
This way having these files