I need to find this number: The '3' on the second column where there is a '3' in the first column.
(This is an example. I also could need to find the '25' on the second column where there is a '36' on the first column).
The numbers on the first column are unique. There is no other row starting with a '3' on the first column.
This data is in a text file, and I'd like to use bash (awk, sed, grep, etc.)
I need to find a number on the second column, knowing the (unique) number of the first column.
In this case, I need to grep the 3 below the 0, on the second column (and, in this case, third row):
108 330
132 0
3 3
26 350
36 25
43 20
93 10
101 3
102 3
103 1
This is not good enough, because the grep should apply only to the first column elements, so the output would by a single number:
cat foo.txt | grep -w '3' | awk '{print $2}'
Although it is a text file, let's imagine it is a MySQL table. The needed query would be:
SELECT column2 WHERE column1='3'
In this case (text file), I know the input value of the first column (eg, 132, or 93, or 3), and I need to find the value of the same row, in the second column (eg, 0, 10, 3, respectively).
Regards,