I have a bash script in which i define a certain path as such:
MY_PATH=/to/my/path
I also have a set of directories within MY_PATH and I store these directories in an array, as such:
DIRECTORIES="/dir1/
/dir2/
/dir3/"
What I want to do is iterate over all the $DIRECTORIES in $MY_PATH, so I tried this:
for dir in $MY_PATH$DIRECTORIES
do
echo "Processing $dir"
end
However, this gives the following undesired output:
Processing /to/my/path/dir1/ #Correct!
Processing /dir2/ #What I want: Processing /to/my/path/dir2/
Processing /dir3/ #What I want: Processing /to/my/path/dir3/
Is there any way to prevent iteration over $MY_PATH while preserving iteration over $DIRECTORIES so that I can achieve the desired output (see above)?