Skip to content

Instantly share code, notes, and snippets.

@peterklipfel
Forked from trinitronx/du_hsort.sh
Created April 5, 2016 16:12
Show Gist options
  • Save peterklipfel/df238b79e3a85917372713bec5c408d7 to your computer and use it in GitHub Desktop.
Save peterklipfel/df238b79e3a85917372713bec5c408d7 to your computer and use it in GitHub Desktop.
Script to sort disk usage output by size
#!/bin/bash
# This line sorts first according to numerical size in bytes
# the second pass through du in the while loop converts to human readable
# format
du -s * | sort -n | cut -f 2- | while read a; do du -hs "$a"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment