Hi
I have assigned list of arrays as below:
rtab[1]="TAB1 Y"
rtab[2]="TAB2 Y"
rtab[3]="TAB3 Y"
rtab[4]="TAB4 Y"
And I have a text file comp.txt that contains
>vi comp.txt
TAB1 Y
TAB2 Y
TAB3 Y
TAB4 Y
I want to compare the content of the array with the content in comp.tx.. so I have written the code as below :
i=0
while read ttab
do
arr[$((i=i+1))]=$ttab
if [ $ttab = ${rtab[i]} ]
then
echo "${rtab[i]} -> status is Y [PASS]"
else
echo "${rtab[i]} -> status is N [FAIL]"
fi
done < comp.txt
But unfortunately I've been getting output ..status is N [FAIL] everytime i run this script.
Is this because the script can't compare 2 words TAB Y ("TAB2 Y" compare with "TAB2 Y" is not permitted, "TAB" compare with "TAB" is OK)?
If yes, how do I rectify this?
Thank u very much 