[NTLUG:Discuss] total drive size
Fred James
fredjame at concentric.net
Wed Mar 12 13:45:34 CST 2003
MadHat wrote:
>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
>
>
>
>
>
And if his orginal question was for the total of all space;
$ ssh dodo df -k | grep "^/dev" | awk '{print Total+=$2 }' | tail -1 |
awk '{print $1/1024, "Mb free"}'
will obviously do it.
--
"It's not nice to fool Mother OS." --anonymous
More information about the Discuss
mailing list