Array error

:slight_smile: Hi,

I am assigning value to array in for loop,
here is the code:

for arg in $FILE
do
TMP=`dirname $arg`
${DIR[i]}=$TMP
echo ${DIR[i]}
let "i = $i + 1"
done

Here TMP gives,
d1/data/BCR
d1/data/BLM

Getting following error:

temp.sh: =d1/data/BCR: No such file or directory
temp.sh: =d1/data/BLM: No such file or directory

Can anyone please advise...

What is in the $FILE variable
ie., show the output of

echo "$FILE"

This is not an assignment.

${DIR}=$TMP

I believe this is what you intended to do:

DIR=$TMP

Thanks mate, its working...