I have been trying to get grep to work to find the intersection between 2 lines:
grep -Fx -f line1.txt line2.txt
Input file contents:
line1.txt:
44.5 -125.0
44.0 -124.5
43.0 -124.3
42.0 -124.0
line2.txt:
43.0 -128.0
43.1 -127.0
43.2 -126.0
43.3 -125.0
43.4 -124.0
43.5 -123.0
43.6 -122.0
43.7 -121.0
The problem is the 2 lines do not have a row that is exactly the same.
Does anyone have a simple way to find the intersecting point?
The following image shows the 2 lines and approx intersection point:
I was hoping to have a command find the intersection point for me. grep probably cannot do this? Also, tried GMT commands, but could not get that to work either. Any advice?
I would settle for a command that would find and write the line2.txt points that are the closest to the intersection:
join
(but beware that its input must be alphabetically sorted, not numerically sorted).grep
capabilities.grep
doesn’t do math. You might be able to do what you want inawk
.