|
|||||||
|
|
11.4. Total Bytes in the Current DirectoryIf you want to know how much space the contents of the current directory take up, you can use something like the following:
Code courtesy of me, Sam Schmit (<id at pt dot lu>), and Sam's uncle Jean-Paul, who ironed out a fairly major bug in my original code, and just generally cleaned it up. Note that you could also just use ls -l | grep ^total | awk '{ print $2 }' because ls -l prints out a line at the beginning that is the approximate size of the directory in kilobytes - although for reasons unknown to me, it seems to be less accurate (but obviously faster) than the above script. Relative speed: this process takes between 3.2 and 5.8 seconds in /usr/bin/ (14.7 meg in the directory) on an unloaded 486SX25, depending on how much of the information is cached (if you use this in a prompt, more or less of it will be cached depending how long you work in the directory). | ||||||
|
|
|
Home :: Copyright :: Privacy :: Credits :: Get a free Linuxinfor Email Account Document on this page is part of "Bash Prompt HOWTO". See Index Page for more info about Authorship and Copyright. 1999-2008 Linuxinfor.com. No rights reserved. |