I'm comparing information between a csv database and PHP table. There are some instances where the PHP table has 'blank' or 'empty' value.
How can I make sure that the comparisons in my if
statement actually compare two values as opposed to one value being compared to a 'blank' value?
This is the snippet of code
if [ "$CSV_PartDir" == "$PHP_PartDir" ] && [ "$CSV_PartName" == "$PHP_PartName" ]
then
echo "MATCH:[$direction / $PHP_PartDir] PN: [$part_name / $PHP_PartNam]"
match=$((match+1))
elif [ "$CSV_PartDir" != "$PHP_PartDir" ] && [ "$CSV_PartName" != "$PHP_PartName" ]
then
echo "WRONG: [$direction / $PHP_PartDir] PN: [$part_name / $PHP_PartNam]"
mismatch=$((mismatch+1))
fi
This is a sample OUTPUT:
MATCH:[OUT / OUT] PN: [JSP-015123 / JSP-015123]
MATCH:[OUT / OUT] PN: [02118 / 02118]
MATCH:[OUT / OUT] PN: [02132 / 02132]
MATCH:[OUT / OUT] PN: [JSP-015123 / JSP-015123]
MATCH:[OUT / OUT] PN: [JSP-015123 / JSP-015123]
WRONG: [OUT / ] PN: [02132 / ]
WRONG: [OUT / ] PN: [02132 / ]
WRONG: [OUT / IN ] PN: [OH-VPS-023 / JSP-01512 ] <--- a "legitimate" comparison to be define as "wrong"
WRONG: [OUT / ] PN: [02132 / ] <--- NOT a "legitimate" comparison to be define as "wrong"
Q: Is there a certain way of checking that the PHP_PartName
and/or PHP_PartDir
actually holds a value as opposed nothing within the if
.
Ideally I would like to print out "wrong" or "mismatch" should my PHP values and CSV values don't match. So I would like to suppress the empty values.