As part of a backup script I want to find the total GB of a list of files to be backed up to see if the supplied USB stick is big enough.
The ideal command is du, for example:
keith@dt05:~$ du -sch Documents Desktop Pictures
2.4G Documents
73M Desktop
1.9G Pictures
4.4G total
keith@dt05:~$
Better still, du has an option to read the file list from a file:
–files0-from=
but the listed file/directory names must be NUL-terminated, and this is where I have become stuck.
A web search indicates “\0” as a null character but adding printf “\0” after a name when creating the file-list does not work, and I’ve tried many other variations offered on the web.
I would be grateful if anyone can suggest a way of listing files/directories in a file so that du will read it.