When the settings data in the array are not displayed with $:
declare -a FILES file_count=0 if [ "$file_ext" != "$SUPPORTED_FILE_TYPE" ] ; then echo "$file_ext is not supported for this task." else FILES[$file_count]=$filename file_count=$file_count+1 fi
FILES without $.
This works for me:
#!/bin/bash declare -a FILES file_count=0 file_ext='jpg' SUPPORTED_FILE_TYPE='jpg' filename='test.jpg' if [ "$file_ext" != "$SUPPORTED_FILE_TYPE" ] ; then echo "$file_ext is not supported for this task." else FILES[$file_count]=$filename file_count=$(($file_count+1)) fi
As you can see, a small modification of $ (()) for the mathematical operation, but the FILES assignments are the same ...
As noted after many tests, Ubuntu, by default, seems to be the dash that caused the error.
source share