PDKSH dual std input threads

Hi All,

I'm trying to read from two files at the same time, but the second READ is failing, giving no value.

Obvious STDIN is being used by the first "while read", so how can I retrieve a value from a second file within the loop ??

IFS=" ," 
cat $DATAFILE | while read curdate currentcksum other filename
do
    grep "$filename" $OLDDATAFILE |read olddate oldcksum other
    STATE=DIFFERENT
    if [[ $oldcksum == $currentcksum ]]    
    then
        STATE=SAME
    fi
    echo $filename,$currentcksum,$oldcksum,$STATE
done

$ ./test1.sh
test/Shortcut to UBUSB.exe.lnk,179426984,,DIFFERENT

oldcksum is empty

using single =
If still does not work, share the sample input and expected output.

IFS=" ," 
cat $DATAFILE | while read curdate currentcksum other filename
do
    grep "$filename" $OLDDATAFILE |while read olddate oldcksum other
    STATE=DIFFERENT
    if [[ $oldcksum == $currentcksum ]]    
    then
        STATE=SAME
    fi
    echo $filename,$currentcksum,$oldcksum,$STATE
done

Hi Guys, Thanks for the reply,

rakeshawasthi: == is correct I think, for testing the values.

danmero: The second "read" should be a single line value return, so no while needed (I'll add a head -1 to it at a later point)

The two input files are:

$DATAFILE:
20090615,179426984 454 test/UBUSB.exe.lnk
$OLDDATAFILE:
20090615,179426984 454 test/UBUSB.exe.lnk

So in this case, oldcksum should return the same 179426984, and then the STATE would be set to SAME.

The whole script, is comparing all of the files in the folder and sub-folder to a list generated x days ago. I need to see which cksums have changed.

-----Post Update-----

So I know the first while loop is reading STDIN. What I cant see is how to get a second read-from-file statement to work.

-----Post Update-----

ok - managed to get it working like this:

cat $DATAFILE | while IFS=", " read curdate currentcksum other filename
do
oldcksum=`grep "$filename" $OLDDATAFILE | cut -f1 -d" " | cut -f2 -d","`
STATE=DIFFERENT

Dont know why that convoluted way works..

-----Post Update-----

ok - managed to get it working like this:

cat $DATAFILE | while IFS=", " read curdate currentcksum other filename
do
oldcksum=`grep "$filename" $OLDDATAFILE | cut -f1 -d" " | cut -f2 -d","`
STATE=DIFFERENT

Dont know why that convoluted way works..