Paste: Simple disk space usage for linux

Author: doublec
Mode: factor
Date: Fri, 10 Oct 2008 01:17:32
Plain Text |
TUPLE: disk-free filesystem size used avail percent mount ;

EBNF: parse-df
spaces = (" " | "\t" | "\n")+
digit = [0-9]
number = digit+ => [[ string>number ]]
filesystem = (!(" ") .)+ => [[ >string ]]
size = number => [[ 1024 * ]]
used = number => [[ 1024 * ]]
avail = number => [[ 1024 * ]]
percent = number "%" => [[ first ]]
mount = (!(" ") .)+ => [[ >string ]]
rule=filesystem:a spaces 
     size:b spaces 
     used:c spaces 
     avail:d spaces 
     percent:e spaces 
     mount:f => [[ a b c d e f disk-free boa ]]
;EBNF

: free-space ( -- seq )
  <process> "df" >>command ascii <process-reader> lines 1 tail [ parse-df ] map ;

New Annotation

Summary:
Author:
Mode:
Body: