Problems with variable

Hey all.

I have trouble passing a variable from inside a loop.

    
    # find all output.txt that has been modified last 24h ...
    PROCESSED=1
    find ${PROCESSED_DIR} -mtime -1 -name "output.txt" | while read i
    do
        # .. and compare those with TMP_TXT
        if diff $i ${TMP_TXT} > /dev/null   
        then
            # If both are same EXIT search loop 
            PROCESSED=0
            exit
        fi
    done
    echo "PROCESSED=${PROCESSED}" 

This will always output 1. Any idea how to make PROCESSED=0 ?

This is done on a Solaris 9 machine.

i think the PROCESSED 0 will only happen if last file is the same with what is being compared.

That's not the problem, avoid the use of a pipe (child shell) something like:

  # find all output.txt that has been modified last 24h ...
    PROCESSED=1

    files=$(find ${PROCESSED_DIR} -mtime -1 -name "output.txt")

    for i in $files
    do
        # .. and compare those with TMP_TXT
        if diff $i ${TMP_TXT} > /dev/null   
        then
            # If both are same EXIT search loop 
            PROCESSED=0
            exit
        fi
    done
    echo "PROCESSED=${PROCESSED}"

Ah, excellent! Tried your solution without the pipe and it worked!

Thanks for help mate!