The GNU Core Utilities are the basic file, shell and text manipulation utilities of the GNU operating system. These are the core utilities which are expected to exist on every operating system.
This post is an elaboration on a feature request I recently sent to the GNU Coreutils mailing list.
I’ve been playing with backups a bit lately, and my favorite command line tool in that effort (other than rsync of course) has been
du—usually known for its annoying recursive and verbose output—but which I just learned to tame with the
--max-depth=1 option, e.g.
$ du -h --max-depth=1 4.0K ./bin 52M ./code 765M ./Desktop 12K ./mail 17M ./music 124K ./PDF 5.5G ./photos 153M ./public_html 652K ./ufc 7.3G .
Perfect! Helps me quickly home in on which directories to trim, and which aren’t worth the bother. The
-h “print[s] sizes in human readable format (e.g., 1K 234M 2G)” but as the list of directories gets longer, it gets harder to differentiate the 153Ms from the 652Ks.
If I don’t use
-h, I can pipe the
du output through
sort -n, but human-readable sizes are so nice. So I proposed to the coreutils group that
sort be extended with an option for sorting by human-readable disk size values. Using the example above, the hypothetical usage and output would look like this:
$ du -h --max-depth=1 | sort -h 4.0K ./bin 12K ./mail 124K ./PDF 652K ./ufc 17M ./music 52M ./code 153M ./public_html 765M ./Desktop 5.5G ./photos 7.3G .
Perhaps it’s time to refresh my knowledge of C?