Geek Posted January 25, 2012 Posted January 25, 2012 <div class="KonaBody"><p><img src="http://osxdaily.com/wp-content/uploads/2012/01/human-readable1.jpg" alt="Human readable output" title="human-readable" width="604" height="114" class="aligncenter size-full wp-image-26421" /></p> <p>The default behavior for most <a href="http://osxdaily.com/category/command-line/">command line</a> tools is to show sizes in bytes, for tiny text files that is fine but when you start working with larger items this becomes difficult to read and interpret. The solutions is fairly simple, pass a “human readable” flag with the command, which will convert bytes to a much more meaningful human readable format of kilobytes (kb) , megabytes (mb) , and gigabytes (gb).</p> <p>Generally, seeing things as human readable is just a matter of <strong>passing an -h flag</strong> along with the command. Three prominent examples are with ls, du, and df: <code>ls -lh</code></p> <p><code>df -h</code></p> <p><code>du -h</code></p> <p>Read on for some specifics about each: <span id="more-26418"></span> <strong>ls</strong> – for the generic list command, you’ll need to attach -h to another flag, like -l:</p> <p><code>ls -lh</code></p> <p><img src="http://osxdaily.com/wp-content/uploads/2012/01/ls-human-readable.gif" alt="human readable ls output" title="ls-human-readable" width="493" height="238" class="aligncenter size-full wp-image-26424" /></p> <p><strong>df</strong> – displaying free disk space with df is infinitely more useful when viewed as human readable. While you can also use a lowercase -h the uppercase is even better on the eyes:</p> <p><code>df -H</code></p> <p><img src="http://osxdaily.com/wp-content/uploads/2012/01/human-readable-df.gif" alt="Human readable df output" title="human-readable-df" width="435" height="108" class="aligncenter size-full wp-image-26420" /></p> <p><strong>du</strong> – displaying disk usage for a specific file, folder, directory, or whatever, is made easier to interpret with -h</p> <p><code>du -sh */</code></p> <p><img src="http://osxdaily.com/wp-content/uploads/2012/01/human-readable-du.gif" alt="Human readable du output" title="human-readable-du" width="340" height="154" class="aligncenter size-full wp-image-26423" /></p> <p><a href="http://osxdaily.com/category/command-line/">Check out more tips and things you can do with the command line</a>.</p> </div> <p><a href="http://feedads.g.doubleclick.net/~a/BAmv2MOVI5jbdVbXELnIDNi0Bh0/0/da"><img src="http://feedads.g.doubleclick.net/~a/BAmv2MOVI5jbdVbXELnIDNi0Bh0/0/di" border="0" ismap="true"></img></a><br/> <a href="http://feedads.g.doubleclick.net/~a/BAmv2MOVI5jbdVbXELnIDNi0Bh0/1/da"><img src="http://feedads.g.doubleclick.net/~a/BAmv2MOVI5jbdVbXELnIDNi0Bh0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare"> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=oJuvLBR38M4:cZyuJvsQVng:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=oJuvLBR38M4:cZyuJvsQVng:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=oJuvLBR38M4:cZyuJvsQVng:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=oJuvLBR38M4:cZyuJvsQVng:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/osxdaily?i=oJuvLBR38M4:cZyuJvsQVng:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=oJuvLBR38M4:cZyuJvsQVng:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/osxdaily?a=oJuvLBR38M4:cZyuJvsQVng:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/osxdaily?d=qj6IDK7rITs" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/osxdaily/~4/oJuvLBR38M4" height="1" width="1"/> View the full article
Recommended Posts