384
edits
Changes
→Overview: du Improved
<code>du</code> is a tool for inspecting directories. It will return the contents of a directory along with how much drive space they are using. However, it can be parse its output quickly, as it usually returns file sizes as a number of bytes:
<code><b>user@host ~ $ du --max-depth 1 /usr/local/lib</b></code>
<pre><code>
164028 /usr/local/lib/heroku
11072 /usr/local/lib/python2.7
8 /usr/local/lib/python3.8
267720 /usr/local/lib
You will therefore be creating a tool called <b>duim (du improved></b>. Your script will call du and return the contents of a specified directory, and generate a bar graph for each subdirectory. The bar graph will represent the drive space as percent of the total drive space for the specified directory.
An example of the finished code your script might produce is this: