[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Invisible contents of a variable array?
From: |
Roger |
Subject: |
Invisible contents of a variable array? |
Date: |
Fri, 20 Jan 2023 20:54:47 -0500 |
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
signature.asc
Description: PGP signature
- Invisible contents of a variable array?,
Roger <=