On 12/09/2016 03:17 PM, Paul Groves wrote:
I appear to have solved it this time! I found a workaround from this page (answer #40) http://stackoverflow.com/questions/9084257/bash-array-with-spaces-in-element...
I have my array (my ISOs in this case): files[0]="/srv/media/PS2 Games/" files[1]="/srv/media/PS1 Games/"
then I have my loop: file_list="" #use variable $file_list for file in ${files[@]}; do file_list="$file_list \"$file\"" done
specifically I replaced: for file in ${files[@]}; do with: for file in "${files[@]}"; do
Without the quotes as above the output of the loop ($file_list) was this: (treating the spaces as separate array items): "/srv/media/PS2" "Games/" "/srv/media/PS1" "Games/"
Now the quotes are added I get as I expected: "/srv/media/PS2 Games/" "/srv/media/PS1 Games/"
With the shell, there are usually many ways to achive a goal. I personally avoid using array shell variables. In this case, I'd probably have used a pipe with xargs. printf '%s\0' \ '/dir/normal/' \ '/dir/with spaces/' \ '/dir/with newline/' \ | xargs -0 tar ... Or I'd have used tar's -files-from= option. Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org