On 2025-07-25, Crystal Kolipe <kolip...@exoticsilicon.com> wrote: > On Fri, Jul 25, 2025 at 07:30:38PM +0200, Kirill A. Korinsky wrote: >> >> Let me quote a man page du(1): >> >> -k By default, all sizes are reported in 512-byte block counts. >> The >> -k option causes the numbers to be reported in kilobyte counts.
but also ENVIRONMENT BLOCKSIZE Block counts will be displayed in units of this size block, unless the -k or -h option is specified. our du doesn't accept BLOCKSIZE=1 though (others do). and this reports disk usage, not file size. $ ls -l /bsd -rwx------ 1 root wheel 32018689 Apr 9 10:13 /bsd $ env BLOCKSIZE=1 gdu /bsd 32047104 /bsd >> If you looking a way to have an accurate size of a file in bytes, use wc You do need read permissions on the file though, and it's inefficient because it reads the file contents, not just metadata. > Or stat -f %z <file> Or gstat -c %s. Out of all of the standard unix utilities, now that most ps(1) are more compatible with each other than in the old days, stat has the least portable syntax out of anything I can think of. Other than wc, I think ls -l | awk is probably the most portable way.