delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/11/15/05:47:23

From: mh AT mike DOT franken DOT de (Michael Hirmke)
Subject: new dfspace
15 Nov 1998 05:47:23 -0800 :
Message-ID: <74vZPfm4pfB.cygnus.gnu-win32@mike.franken.de>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

Hi *,

whoever might be interested - here is a new version of dfspace:

------------------------< snip snip snip >-----------------------------
#!/bin/sh -
#ident "@(#)$Header: dfspace,v 1.3 92/09/14 15:42:50 hannibal Exp $ SNI"
# @(#)dfspace        Revision: 1.7     2/26/91 14:09:51
#

#ident  "@(#)adm:dfspace  1.8.1.4"
# dfspace - d(isk) f(ree) space
#
# Calculate available disk space in all mounted filesystems
# with the exception of psuedo file systems such as /proc and /dev/fd.
#
# Alternately, report on filesystems/devices specified on cmd-line.
#   Filesystem may be 1K bytes/block, but, df uses 512 bytes/block.
#

# get free and allocated space.
df -k $* 2>/dev/null | awk '
BEGIN { AVAIL = 0; TOTAL = 0; SAV = "" } {
  if ( $6 != "/proc" && $6 != "/dev/fd" && $1 != "Filesystem" ) {
    # print $1 $2 $3 $4 $5 $6
    if( length( $2 ) == 0 ) {
      SAV = $1
    } else {
      if( length( SAV ) > 0 ) {
        AVAIL += $3
        TOTAL += $1
        while( length( $5 ) < 28 ) $5 = $5 " "
        printf( "%.28s: %#7.2f MB of %#7.2f MB available (%#6.2f%%)\n",
                 $5, $3 / 1024, $1 / 1024, $3 * 100 / $1 )
        SAV = ""
      } else {
        AVAIL += $4
        TOTAL += $2
        while( length( $6 ) < 28 ) $6 = $6 " "
        printf( "%.28s: %#7.2f MB of %#7.2f MB available (%#6.2f%%)\n",
                 $6, $4 / 1024, $2 / 1024, $4 * 100 / $2 )
      }
    }
  }
}
END {
  printf( "-------------------------------------------------------------------------------\n" )
  printf( "%s: %#7.2f MB of %#7.2f MB available (%#6.2f%%)\n",
          "            Total           ",
          AVAIL / 1024, TOTAL / 1024, AVAIL * 100 / TOTAL )
}'

# end of disk space calculation.
------------------------< snip snip snip >-----------------------------

Bye.
Michael.
--
Michael Hirmke           | Telefon +49 (911) 557999
Georg-Strobel-Strasse 81 | FAX     +49 (911) 557664
90489 Nuernberg          | E-Mail  mailto:mh AT mike DOT franken DOT de
                         | WWW     http://aquarius.franken.de/
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019