Hello Everyone,
My question is How can we compare two files might be having same data with few differences, Data are not in columns, but they are segregated position wise.
So we would require to compare each line characters with another.
I tried to use sdiff command also but it shows at which line differences are present.
sdiff $file1 $file2 | cat -n |grep "|" > log file
Also tried to create one more script but it is taking so much time.
================================================================================
for i in `cat /testfile1`
do
for j in `cat /testfile2`
do
for ((k=0;k <=`echo $i | wc -c `;k++))
do
a=${i:k:1}
b=${j:k:1}
if [ "$a" != "$b" ]
then
lineno=`grep -n "$i" /testfile1 | cut -d ":" -f 1`
echo "mismatch is at line no $lineno at position $k" >> /test_log_file
fi
done
#cat /home/okanung/test_handoff/test_log_file| sort -n |uniq -c >final_test_log_file
done
done
================================================================================
Please help for same.If anybody have any idea on same.You can share your own script as well.
My question is How can we compare two files might be having same data with few differences, Data are not in columns, but they are segregated position wise.
So we would require to compare each line characters with another.
I tried to use sdiff command also but it shows at which line differences are present.
sdiff $file1 $file2 | cat -n |grep "|" > log file
Also tried to create one more script but it is taking so much time.
================================================================================
for i in `cat /testfile1`
do
for j in `cat /testfile2`
do
for ((k=0;k <=`echo $i | wc -c `;k++))
do
a=${i:k:1}
b=${j:k:1}
if [ "$a" != "$b" ]
then
lineno=`grep -n "$i" /testfile1 | cut -d ":" -f 1`
echo "mismatch is at line no $lineno at position $k" >> /test_log_file
fi
done
#cat /home/okanung/test_handoff/test_log_file| sort -n |uniq -c >final_test_log_file
done
done
================================================================================
Please help for same.If anybody have any idea on same.You can share your own script as well.