0

I don't understand why comparing strings is not working here:

while IFS=, read -r ELMS_SIZE ELMS_NAME ELMS_ENV ELMS_DB
do

if [ "${ELMS_DB}" = "NOMATCH" ]; then
 echo "done"
fi

done < <(tac ${CSM_DATA_DIR}/test.csv)

exit

ELMS_DB has string value of NOMATCH, example of output for test.csv

12 am_pltconfig9 unknown NOMATCH
12 am_pltconfig8 unknown NOMATCH
12 am_pltconfig7 unknown NOMATCH
12 am_pltconfig6 unknown NOMATCH
0

1 Answer 1

2

Based on your example of test.csv, your file is not actually comma separated but space separated instead. Try changing your while read loop to:

while read -r ELMS_SIZE ELMS_NAME ELMS_ENV ELMS_DB
do
  if [ "$ELMS_DB" = "NOMATCH" ]; then
   echo "done"
  fi
done < <(tac "${CSM_DATA_DIR}/test.csv")

exit
2
  • thanks Jesse_b, I tried up voting and green check your comment it's not working due to reputation. This is PERFECT answer, thanks. :) Commented May 3, 2019 at 15:02
  • Glad I could help. Accepting an answer (green check) can be done at any level of reputation though. Commented May 3, 2019 at 15:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.