I have a bash script which seems to lose the value of the readonly constant after the first time thru the for-in loop. For example:
#!/bin/bash
readonly DIR="./groups/"
for output in "${array[@]}"
do
catstring+="$DIR$output "
done
printf "$catstring"
cat $catstring > outputfile
The array has a bunch of names in it like: file1 file2 file3, etc.
The output from the printf statement is "./groups/file1 file2 file3". What I'm expecting is "./groups/file1 ./groups/file2 ./groups/file3".
Why is bash losing the value of $DIR after the first time thru the for-in loop?