I have a problem with writing a bash script and hope that someone can help me with this. I have written a few smaller scripts in bash before, so I'm not totally new, but there's still lots of space for improvement.
So, I have a file that only contains two columns of decimal numbers, like:
0.46 0.68
0.92 1.36
1.38 2.04
1.84 2.72
2.3 3.4
2.76 4.08
3.22 4.76
3.68 5.44
4.14 6.12
...
What I want to do is to compare every number in the first column with every number in the second column and check, if any two numbers are equal and print this number then to the screen or a file.
I found an answer for how to do this in an excel table, but I would be really interested in how to do this in bash or maybe with awk.
The first problem for me is that I don't even know how I would compare the first number to all others in the second column. I guess that I would have to do this via arrays. I could read the two numbers by a 'while read var_1 var_2' command and then I would have to somehow add var_1 of each line to an array_1, same for var_2 for another array_2 and then I somehow would have to compare all the elements with each other.
But I don't know how to. I hope someone can help me.