Finding PID of a process using variable substituition

Hi All,
Am copying mulitple files in a directory in names File0,File1,File2 etc.
I need to print separately the PID of these copies using File names.

for((i=0;i<5;i++))
do
mypid=`ps aux | awk '/File$i/ && !/awk/ { print $2 }'`
echo PID is $mypid
done

It printed nothing. Thinking "File$i" is not found. Am i right? Is there a way to find the PID of a process using variable substituition? If not, how it cud be achieved?

FYI,I got the PID of FIle0 or FIle1 if i use its name specifically like,

mypid=`ps aux | awk '/File0/ && !/awk/ { print $2 }'`
echo PID is $mypid

Thanks,
Amio

try

ps aux | awk '/File$i/ && !/awk/ { print $2 }' & mypid=$!
echo mypid

To use the Shell variables, use "-v i.e. Variable" option in awk.

Do this:
fname=File$i
mypid=`ps aux | awk -v var="$fname" 'BEGIN /var/ && !/awk/ { print $2 }'`

Note, that your shell variable is fname...which the filename
and the corresponding awk variable is "var"
Hope this helps.

Thanks friends for ur replies.

amio.

Have you tried what you've suggested?

fname=File$i
mypid=`ps aux | awk -v var="$fname" '$0 ~ var && !/awk/ { print $2 }'`

ps aux | awk '/File$i/ && !/awk/ { print $2 }' & mypid=$!
echo mypid

worked for me..
Thanks

mypid=`ps -w aux | awk '/'"$myvar"'/ && !/awk/ { print $2 }'`
echo PID is $mypid

It also gives the PID using variable subtituition..
Thanks