I have a list of files and folders assigned to variable _files[] array.
For calculating the total size of a list of files and folders, I am using du
with _files[@], I then get a division by zero warning.
du --bytes --total "${_files[@]}" | tail --lines=1 | cut --fields=1
du: invalid zero-length file name
Printing the contents of the variable _files[@] array only obviously prints
visible files/folders.
My guess is, without reading extensively into the bash manual, du is also being
passed a null termination character? Crazy guess, as the du size in bytes is
so far correct.
Is there anything I can do to prevent this division by zero operation, or just
quietly the error by passing the output to /dev/null?
Roger