I want to find out total size of some files which filenames may contain whitespaces:
cd /tmp
touch "a0 1"
touch "a1 1"
I put these filenames to variables and make a list:
var0="/tmp/a0 1"
var1="/tmp/a1 1"
var2=`echo -e "$var0\n$var1"`
Now if I check myself and print this list, everything seems OK:
echo "$var2"
#returns:
#/tmp/a0 1
#/tmp/a1 1
But if I try to get the total size, it somehow misunderstands "\n" symbol
du "$var2"
#returns:
#du: cannot access ‘/tmp/a0 1\n/tmp/a1 1’: No such file or directory
How do I make du process "\n" as line separator? Or maybe I have to create list in a different way?