Tag: du

  • How to sort the result of du -h command

    How to sort the result of du -h command

    To sort the result of “du -h” command, you can use

    du -h --max-depth=1 | sort -h
    

    If you want to list files in current files also, you can use

    du -ah --max-depth=1 | sort -h
    

    If you want to display files in KB, you can use

    du -k --max-depth=1 | sort -n
    

    Back to Disk Usage

  • Find Disk Usage in Linux

    du command shows disk usage.

    du -h --max-depth=1

    If you want to sort the result, see How to sort the result of du -h command

    To see disk usage on the current partition only, run

    du -hx --max-depth=1

    To sort by disk space

    du -k --max-depth=1 | sort -n

    To display the top 20 largest folders/files

    du -ahx . | sort -rh | head -20
    du -h | sort -hr | head -n  30