I want to display all directories that are smaller than 4MB using find command.
Already tried find / type d -size -4000000c(same with a dot instead of
/`) but both combinations display files too. What kind of switch should I put here to search only for directories? Maybe there is another command for this purpose?
du
command.To list content of all directories in Mb units:
du -m / 2>/dev/null
-m
produce directory size in Mb.
/
start inspecting from root directory (hope you know what you are doing)
2>/dev/null
ignore all errors related to directories access
awk
scriptdu -m / 2>/dev/null | awk '$1 < 4 {print $2}'
$1 < 4
filter only lines where 1st field less than 4
{print $2}
from filtered line print 2nd field