Problem one seems to be a mix of UTF-8 and ASCII quotation marks
(")
in your code -- assuming you did a cut&paste from your source.
Next, your logic is slightly off. You break the while loop and report no matches on the
first non-match. One possible solution:
let ITER=0
while read record
do
if [[ ! "$record" =~ "${ITEM}" && "$record" =~ "${QTY}" ]]; then
echo "posible match : $record"
let ITER+=1
fi
done < scanlist.csv
if [[ $ITER -eq 0 ]]; then
echo "no matches found"
fi
Also note that this
for i in "${ADDR[@]}"; do
echo "Possible matches: "${ADDR[@]}.
prints all items in the array for each array element, which is probably not what you want. Since
i
is an array element, not the index, you can manipulate the array element using
$i
. To access the array via an index, you can use
i = ${!ADDR[@]}