AWK pattern matching on loop

Hi,

I am still a beginner on shell scripting so please bear with me.

What i am trying to do is filter my logfile based on some ID on field 24 which is defined in array. The filter result output will be moved to my log folder with the same name. The problem is when not using loop, this command can work.

awk '$24 == 32596 ' program/application/logs/archive/click/$x >> log/$x

But when using loop, my script wont work. Please notice the bold variable.

id=(32596 32595 32594 32589 32580 32579); for x in `ls`;do for y in ${id[@]}; do awk '$24 == $y ' program/application/logs/archive/click/$x >> log/$x;done;done

Is there something i must or change to get this script working?

Thanks before for answering.

Hi

awk -v y=$y  '$24 == y' program/application......

Works like a charm. Thanks