With the following code I wish to check each index in an array for a null value, an empty string, or a string containing just white space. However it is not working.
test=( "apple" "orange" " ")
for i in ${test[@]};
do
if [ -z "$i" ]; then
echo "Oh no!"
fi
done
It never enters the if block. What am I doing wrong?
${test[@]}as it will currently strip out whitespace and empty values