I'm working on a bash script for my server backup. Based on my web root(/home), I wanna filter my web directories excludes something generals. I found --ignore option for it. Here's my code for returng what I want.
DIR_LIST=`ls -al $WWW_ROOT --ignore={.,..,ubuntu,test} | grep "^d" | awk '{ print $9 }'`
echo $DIR_LIST;
But when I tried with array, it's not worked as well.
EXCLUDED=(. .. test ubuntu)
STR=$(IFS=,; echo "${EXCLUDED[*]}")
DIR_LIST=`ls -al $WWW_ROOT --ignore={$STR} | grep "^d" | awk '{ print $9 }'`
echo $DIR_LIST;
echo $STR works well but echo $DIR_LIST is not. I think brace is not worked properly.
How can I do this as I expected?