#!/bin/csh ## csh script: total ## --- compute total disk space in bytes for a directory hierarchy ## a recursive script if ( $#argv == 1 && -d $1) then set x = `/bin/ls -l -d $1` else echo usage : $0 directory; exit(1) endif set count = $x[5] ## initialize byte count foreach file ( $1/* $1/.* ) if ( -f $file ) then set x = `/bin/ls -l $file` @ count = $count + $x[5] else if ( $file:t == "." || $file:t == ".." ) then continue else if ( -d $file ) then set y = `$0 $file` ## recursive call @ count = $count + $y else echo $file not included in the total >>! /tmp/total.file endif end echo $count