Unix – How to compare two files in shell script

filecompareshellunix

Here is my scenario.
I have two files which are having records with each record's 3-25 characters is an identifier. Based on this I need to compare both of them and update the old file with the new file data if their identifiers match. Identifiers start with 01.
Please look at the script below.
This is giving some error as "argument expected at line 12 which I am not able to understand.

#!/bin/ksh
while read line
  do
    c=`echo $line|grep '^01' `
    if [ $c -ne NULL ];
      then
        var=`echo $line|cut -c 3-25`
    fi
    while read i
      do
        d=`echo $i|grep '^01' `
        if [ $d -ne NULL ];
          then
            var1=`echo $i|cut -c 3-25`
            if [ $var -eq $var1 ];
              then
                $line=$i
            fi
        fi
      done < test_monday
  done < test_sunday

Please help me out thanks in advance

Best Answer

I think what you need is :

if [ "$d" != NULL ];

Try.