[NTLUG:Discuss] total drive size

MadHat madhat at unspecific.com
Wed Mar 12 12:15:03 CST 2003


On Wed, 2003-03-12 at 11:49, MadHat wrote:
> On Wed, 2003-03-12 at 11:25, Rev. wRy wrote:
> > Bishop, Cass wrote:
> > 
> > > What I was hoping for is a command, or series of commands that can get the
> > > info for each partition then total it up for me.  I have started with this
> > > to get a list of partition sizes but I'm not sure what to do with it now.  I
> > > need to total this number and make it human readable(like the df -h option).
> > > 
> > > df|cut -c 20-29|grep -v block
> > 
> 
> ok, try this...
> 
> $ for i in `df -k | grep "^/dev" | awk '{print $3}'`; do total=`dc -e
> "$i $total + p" 2>/dev/null`; done; total=`dc -e "$total 1024 / p"`;
> echo "total Mb used $total"
> 
> Will print total Mb used on the computer
> 
> It would be easier to script, but...

better yet, just use awk (wasn't thinking before)
df -k | grep "^/dev" | awk '{print Total+=$3 }' | tail -1 | awk '{print
$1/1024, "Mb used"}'

which works with SSH
$ ssh dodo df -k | grep "^/dev" | awk '{print Total+=$3 }' | tail -1 |
awk '{print $1/1024, "Mb used"}'
4638.88 Mb used

want to know free?
$ ssh dodo df -k | grep "^/dev" | awk '{print Total+=$4 }' | tail -1 |
awk '{print $1/1024, "Mb free"}'
12722.4 Mb free



-- 
MadHat at Unspecific.com
`But I don't want to go among mad people,' Alice remarked.
`Oh, you can't help that,' said the Cat: `we're all mad here...'
   -- Lewis Carroll - _Alice's_Adventures_in_Wonderland_




More information about the Discuss mailing list