Your script should look more like ...
for N in $(seq 1 10000)
EXIST_MLNET=$(cat /proc/"$N"/status 2>/dev/null | grep "mlnet")
if [ "$EXIST_MLNET" = "Name: mlnet" ]
echo $N > /home/andy/Temp/mlnet.found
Use the for loop since you are counting, and it saves you from having to increment N. I also added pipping the standard errors from cat to /dev/null so that you won't see a message everytime you try to access a process that doesn't exist. The only thing that you are going to want to watch out for is if you have more than one process with mlnet in it. The > redirect will over-write that file, so you will only end up with the last occurrance. You can use >> if you want to append to that file everytime it finds an instance. If this is the case, add an rm statement to the beginning of the script so that you get clean data everytime.
If you were to use your while loop, your condition would be $N -lt 10000, and not what you have. incr is not a Bash command either. You'd need to use
to increment your value.
Check out the Advanced Bash Scripting guide at
for a good over-view of the Bash scripting language. Lots of good information in there.
I agree though. There are easier ways to find the pid of a process.