How to grep nth word in line?

my input file content is like this

GEFITINIB 403 14 -4.786873 -4.786873 -1.990111 0.000000 0.000000 -1.146266 -39.955912 483
VANDETANIB 404 21 -4.754243 -4.754243 -2.554131 -0.090303 0.000000 -0.244210 -41.615502 193
VANDETANIB 405 21 -4.737541 -4.737541 -2.670195 -0.006006 0.000000 -0.285579 -40.793145 472
PELITINIB 406 20 -4.697441 -4.697441 -1.154811 -0.323963 0.000000 -0.238975 -37.666605 934 
Neratinib 40 19 -4.680369 -4.680369 -1.618439 -0.196470 0.000000 -0.001702 -51.090346 405
1m17-co 408 1 -4.643390 -4.643390 -1.279303 -0.455054 0.000000 -0.899078 -39.117333 429
1m17-co 409 1 -4.634879 -4.634879 -1.465411 -0.430470 0.000000 -0.900950 -38.233987 405

my output should be line whose second word is 405

VANDETANIB 405 21 -4.737541 -4.737541 -2.670195 -0.006006 0.000000 -0.285579 -40.793145 472

If I use grep command

grep 405 file

it gives three lines

VANDETANIB 405 21 -4.737541 -4.737541 -2.670195 -0.006006 0.000000 -0.285579 -40.793145 472
Neratinib 40 19 -4.680369 -4.680369 -1.618439 -0.196470 0.000000 -0.001702 -51.090346 405
1m17-co 409 1 -4.634879 -4.634879 -1.465411 -0.430470 0.000000 -0.900950 -38.233987 405

but I want only the line whose second word is 405

Thanks in advance

awk '$2==405' inputfile

Is probably the simplest way to do this. Using regular expressions which you would need for grep are a little more complex.

Its working
Thank you very much

Hello,

One more approach, may help. Let us say check_second_field file have the input data.

awk -F" " -vs1="405" '{
        v=$2;
        if(v==s1)
        print $0 }' check_second_field

Output will be as follows.

VANDETANIB 405 21 -4.737541 -4.737541 -2.670195 -0.006006 0.000000 -0.285579 -40.793145 472

Thanks,
R. Singh

Thanks its working

---------- Post updated at 06:36 PM ---------- Previous update was at 06:35 PM ----------

Thank you very much