1

This system is linux mint 18.3, basically ubuntu.

sudo du --apparent-size -sb /tmp yields 476mb on my system currently.

if I run sudo du --apparent-size -sb /tmp/* /tmp/.??* and add it all up, I get about 4mb.

(I know -b includes --apparent-size, just want to be explicit for this question)

Actually, to find the sum since I'm lazy, so I ran:

sudo du --apparent-size -sb /tmp/* /tmp/.??* | cut -f 1 | paste -sd+ - | bc

Why the difference? Are there some hidden files in /tmp that du isn't finding, or is there a mistake in my commands?

edit: despite my poor .??* to catch .dirs and .files, there were no .a, .b, .c etc files in this case.

  • 3
    Possibility: you have large files names .a, .b, etc. (. with single character after it)? – muru Apr 6 '18 at 4:36
  • 2
    This is not a duplicate, because the OP is using THE SAME TOOL to measure THE SAME FILES, whereas the possible duplicates compare the outputs of different tools and/or different copies of a file. The comment/answer by @muru is a distinct possibility in this scenario, but never in the possible duplicates. – Bananguin Apr 6 '18 at 10:19
  • @muru - I looked to see if there were .a etc that .??* would miss - no, there weren't. – marathon Apr 7 '18 at 1:16
4

One way to reproduce this case is to create lots of empty files (ideally of long filename length) which will expand the size of the directory (.) where the filenames are stored but not the size of the files (and * does not match the directory where those filenames are stored):

% mkdir emptydir && cd emptydir
% du --apparent-size -sb .
6       .
% du --apparent-size -sb * | cut -f 1 | paste -sd+ - | bc
zsh: no matches found: *
% jot 100000 | while read n; do touch $n; done
% du --apparent-size -sb .
2359296 .
% du --apparent-size -sb * | cut -f 1 | paste -sd+ - | bc
0

So we've here taken the empty directory from 6 to 2359296 while the glob version still totals zero because the files created are all empty.

|improve this answer|||||

Not the answer you're looking for? Browse other questions tagged or ask your own question.