Edited*I have the following definitions in my bash script:DATE_SUFIX=$(date +%F_%H-%M-%S)NAME=MyBackup_FILE_NAME=$NAME$DATE_SUFIXTMP_DIR=/tmp/TMP_BKP=$TMP_DIR$NOME_ARQ/TAR_CMD=tar czPf and I create a dir list like this:FOLDER_LIST[0]=/optFOLDER_LIST[1]=/etc/apache2/sites-availableFOLDER_LIST[2]=/home/userThen I iterate this list with this loop:mkdir $TMP_BKPfor ix in ${!FOLDER_LIST[*]}do    CMD=$TAR_CMD$TMP_BKP$(basename ${FOLDER_LIST[$ix]}).tar.gz ${FOLDER_LIST[$ix]}/* $EXCLUDE    echo $CMDdoneI also have some code to generate the $EXCLUDE part. I does it the same way. But the relevant part of code for this question is that ${FOLDER_LIST[$ix]}/* part in CMD expands to:/home/user/mybackupfolder/foo /home/user/mybackupfolder/bar ...the problem is that one of the expanded sub-folders has spaces in it, generating:/home/user/mybackupfolder/foo /home/user/mybackupfolder/bar /home/user/mybackupfolder/my spaced dirand that breaks the following operations. How can I make it expand to this? -'/home/user/mybackupfolder/foo' '/home/user/mybackupfolder/bar' '/home/user/mybackupfolder/my spaced dir'
How to include single quotes in bash folder expansion?
bash
(Answer culled from comment thread)This seems to be a case where quotes are either missing or wrongly applied. You cannot put quotes into a string and have the shell to interpret the result as a quoted string.Please could I suggest that you read BashFAQ #50: I'm trying to put a command in a variable, but the complex cases always fail! and see if that helps.