Home Linux Programming Snapshot – Disk Space Analyzer » Linux Magazine

Programming Snapshot – Disk Space Analyzer » Linux Magazine

Programming Snapshot – Disk Space Analyzer » Linux Magazine

This month, Mike Schilli writes a quick terminal UI in Go to help track down space hogs on his hard disk.

When installing a new hard disk, users think they are in seventh heaven – it seems almost impossible to ever fill up the drive. Given today’s huge capacities, though, virtually everyone becomes a thoughtless space waster sooner or later. As the disk fills up, space needs to be freed up to keep things going. Most of the time, the culprit is huge files no longer in use that are still hanging around in forgotten directories and causing overcrowding. The most effective strategy is often a simple one of tracking down the biggest space wasters and then deleting the unneeded files.

The spacetree Go program helps with this housecleaning by pointing to the most storage-intensive paths starting from a root directory and provides their disk space usage in bytes. As Figure 1 shows, the Go binary, which you call with the directory to be analyzed, switches the terminal to graphics mode and displays the storage paths as an interactive tree. You can expand the green elements in the tree with a mouse click or by pressing the Enter key to determine which folders contain the fattest files.

Biggest Fish

In Figure 1, the Go spacetree binary takes a look at the ~/git/ directory and discovers some 14GB of data there. Using the arrow keys, their vi equivalents J and K, or even the mouse if you fancy, you can navigate to the directories highlighted in green and expand them by pressing the Enter key. Figure 2 shows that, for example, the articles/ directory, which contains the articles from 26 years of this column, occupies a total of almost 4GB.


Use Express-Checkout link below to read the full article (PDF).

Source link

netbalaban news