[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Invisible contents of a variable array?
From: |
Greg Wooledge |
Subject: |
Re: Invisible contents of a variable array? |
Date: |
Fri, 20 Jan 2023 21:19:30 -0500 |
On Fri, Jan 20, 2023 at 08:54:47PM -0500, Roger wrote:
> 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.
You're gonna need to show us how you populated the array, and what's
actually in the array (declare -p _files).
unicorn:~$ du --bytes --total ""
du: invalid zero-length file name
0 total
It's pretty obvious you've got an empty string in the array, but without
showing us how you populated it, we can't help you much.