Created
April 25, 2017 04:47
-
-
Save pilgrim2go/582bf5ac2d58883a65c8e5973c6d2e8e to your computer and use it in GitHub Desktop.
Sort disk usage using df command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From: https://lists.gnu.org/archive/html/bug-coreutils/2007-01/msg00131.html | |
``` | |
df -Pk | tail -n +2 | sort -k3,3n | |
``` | |
Or if you want to preserve the header, use a script like this: | |
#!/bin/sh | |
df -Pk > /tmp/df.$$ | |
(head -1; sort -k3,3n) < /tmp/df.$$ | |
rm -f /tmp/df.$$ |
thanks for that, and a little improvement, make it human readable:
df -h | sort -k4 -h # sort by 4th field (Available) human-numeric-sort
df -h | sort -k5 -g # sort by 5th field (Use%) numerically
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
another way to sort