du
and find
command. If you want to learn more about these two commands, then head over to the following articles./home
partition.du
command: Estimate file space usage.a
: Displays all files and folders.sort
command : Sort lines of text files.-n
: Compare according to string numerical value.-r
: Reverse the result of comparisons.head
: Output the first part of files.-n
: Print the first ‘n’ lines. (In our case, We displayed first 5 lines).du
command: Estimate file space usage.-h
: Print sizes in human readable format (e.g., 10MB).-S
: Do not include size of subdirectories.-s
: Display only a total for each argument.sort
command : sort lines of text files.-r
: Reverse the result of comparisons.-h
: Compare human readable numbers (e.g., 2K, 1G).head
: Output the first part of files.find
command:/home/tecmint/Downloads
directory.dir /O:-S
command, and although it sorts files just fine, it doesn't seem to order the subdirectories.c:folder
to the folder level you want to query. cmd /v /c 'set zeropad=000,000,000,000,000,&for /f 'delims=' %a in ('dir /ad /b') do @set bytes=!zeropad!000&(for /f 'tokens=3' %b in ('dir /s '%a' 2^>NUL ^| find 'File(s)') do @set bytes=%b)& @for /f 'tokens=1* delims=,' %c in ('echo !bytes!') do @(set bytes=%c&@set bytes=000!bytes!&@set bytes=!bytes:~-3!& @set bytes=!zeropad!!bytes!&if '%d' NEQ ' set bytes=!bytes!,%d) & @echo !bytes:~-23! %a' | sort /R
d:files
is the target tree here.