finding number in exact column

Dear all,

I want to find a number in exact column but I don't know how to do it.

Here is the thing, data is shown below, and I want to find 416 in the first column and print it out, how should I deal with it? Thank you very much!

ab33 50S01S 958 279.068999 67.251013 -150.172544 67.250000 -150.166667 1.000000 
p721 10D07S 670 360.080693 45.002876 -110.002049 45.000000 -110.000000 2.000000 
p682 10G08S 730 720.072461 42.503302 -110.907523 42.500000 -110.900000 1.000000 
yac 45L01S 1073 918.272412 60.548704 -145.749858 60.550000 -145.733333 1.000000 
p716 10E03S 384 929.291764 44.718258 -110.511512 44.716667 -110.500000 7.000000 
p434 21B01S 791 958.767801 47.740203 -121.075609 47.733333 -121.083333 1.000000 
385 21E05S 733 1008.105624 44.434844 -121.945818 44.433333 -121.933333 1.000000 
703 22C13S 1012 1129.240237 46.145300 -122.196290 46.150000 -122.183333 7.000000 
ab39 45R01S 961 1239.222796 66.559346 -145.212631 66.566667 -145.233333 1.000000 
416 21B62S 928 1522.856762 47.039940 -121.596930 47.050000 -121.583333 1.000000 
lid 19K07S 652 1587.198692 39.314277 -119.884287 39.300000 -119.883333 3.000000 
p680 11E31S 609 1681.722583 44.598357 -111.098749 44.583333 -111.100000 1.000000 
p351 14F12S 490 1765.354757 43.874415 -114.719163 43.866667 -114.700000 1.000000 
p024 15B09S 803 2367.486094 47.562202 -115.842434 47.550000 -115.816667 1.000000 
p700 22C10S 748 2586.572452 46.178130 -122.217349 46.183333 -122.250000 12.000000 
p708 10F30S 1082 2590.800887 43.786390 -110.933579 43.766667 -110.916667 4.000000 
p692 22C12S 777 3142.166348 46.224494 -122.184192 46.250000 -122.166667 5.000000 
p698 22C13S 1012 3144.877395 46.173466 -122.160611 46.150000 -122.183333 7.000000 
p713 10E07S 816 3155.919570 44.389671 -110.543734 44.366667 -110.566667 2.000000 
p690 22C13S 1012 3373.068445 46.179989 -122.189869 46.150000 -122.183333 7.000000 
p699 22C10S 748 3681.617055 46.189783 -122.203226 46.183333 -122.250000 12.000000 
ikr 50O01S 1072 3758.505227 63.552727 -150.922211 63.533333 -150.983333 3.000000 
791 21D08S 651 3765.896876 45.344531 -121.672684 45.316667 -121.700000 1.000000 
735 23G09S 558 3770.273135 42.691610 -123.230999 42.716667 -123.200000 10.000000 
rn86 11H60S 1098 3930.588800 41.864856 -111.502514 41.900000 -111.500000 2.000000 
tah 11H60S 1098 3931.080070 41.864854 -111.502574 41.900000 -111.500000 2.000000 
p697 22C13S 1012 4218.251803 46.187642 -122.176609 46.150000 -122.183333 7.000000 
p693 22C10S 748 4747.385902 46.210322 -122.202348 46.183333 -122.250000 12.000000 
p705 22C10S 748 4820.487371 46.173000 -122.310630 46.183333 -122.250000 12.000000 
798 10F30S 1082 4822.886202 43.796028 -110.960579 43.766667 -110.916667 4.000000
awk '$1 == 416' file
1 Like

Thanks for you response.

I have another question about it, that is ,when I get the number(416), how can I print out the number in the 3rd column of this row(928)?

Thanks!

---------- Post updated at 01:40 PM ---------- Previous update was at 01:31 PM ----------

Do I need a loop? Use foreach?

Thanks

No, awk checks the expression against every line in the file, sort of like how grep does. But awk has comparisons and variables and all the things you need to actually write a program, where grep can only match and print lines.

awk '$1 == 416 { print $3 }' file

Thanks, it works when searching for 416, but it fails when searching for 'ab33' for example.

awk '$1 == "ab33" { print $3 }' infile