I have a directory called 'directory1' with files: file1, file2, file3, that have been passed by in a variable 'files'. Echo $files has the following output: file1 file2 file3. I want to have the sum of the sizes but the code below only works for only one file. How can I make it work for all the files?
ls -l ./$dir/$files | awk '{t+=$5}END{print t}'