if [ $Total_col_count -eq 10 -a $Temp_var == $head_file ]
Thanks for the swift response but still facing the same. As I am guessing the row having double quotes that's way it is comparing. still unable to find the root cause.
error message
0403-012 A test command parameter is not valid.
Temp_var=`echo '"CUST_INFO","CUST_NAME","CUST_AGE"'`
head_file=`head -1 customer_file.txt`
Total_col_count=`awk -F"," '{print NF}' customer_file.txt|sort -u`
if [ $Total_col_count -eq 10 -a $Temp_var == $head_file ]
then
echo "matched"
else "not matched"
fi
More chances that Total_col_count variable to hold more than one value in your case. So the if condition fails as your comparing it with single value 10. Print the value of Total_col_count and check before going for if condition to make sure it holds only single value and not multiple.
Ok.So your sure that the file customer_file.txt contains only one line.. Or many lines with same number of columns..? One little bug is that there is no echo statement in the else part.
if [ $Total_col_count -eq 10 -a $Temp_var == $head_file ]
then
echo "matched"
else
echo "not matched"
fi