need help in disk space commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help in disk space commands
# 1  
Old 09-17-2008
need help in disk space commands

hy i have written a K-shell script that will calculate the number of Disk space used by all the directories under the HOMe dir

#!/bin/ksh

cd /ednpdtu3/u01/pipe

count=`ls -ltr | grep ^d | wc -l`
echo "$count Dir found in HOME DIR"

a1=1
while [ $a1 -le $count ]
do
b=`ls -ltr | grep ^d | head -$a1 | tail -1 | tr -s " " | cut -d " " -f9`
#echo $b
a1=`expr $a1 + 1`
a2=`du -m $b`
echo "The size of $b is $a2"

done
----------------------------------------------------------------------

My home Dir contains 21 Dir. how u get those directories space utilised in MB.

here in my script du -m is not giving proper results

I have a dir called AMIS_Scripts whose total size in MB is 4497.44

but my script is giving results as

The size of AMIS_Scripts is
27.46 AMIS_Scripts/Oncor_exc_miss_rep
4469.52 AMIS_Scripts/temp
4497.44 AMIS_Scripts MB

I dnt want the result of Sub-dir inside AMIS_Scripts to show up, just want the total disk space used in MB by AMIS_SCRIPTS dir to show up in my output

Plz help me in this

Last edited by ali560045; 09-17-2008 at 03:08 AM..
# 2  
Old 09-17-2008
Hi

du -h gives you the correct result.

a2=`du -h $b`
vamsi.risingsun
# 3  
Old 09-17-2008
du -h is not working in my system. i m using IBM AIX 3.5
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Disk Space

I know there are other threads but they have not helped. My server is running low on disk space and I haven't been able to re-allocate. I think my solaris machine is missing tools or the way it was originally setup, may not have the right pathing. $ df -k Filesystem kbytes used... (5 Replies)
Discussion started by: lnxjenn
5 Replies

2. Shell Programming and Scripting

disk space

Hi, I am new to shell scripting, and want to monitor disk space using shell script continously on server, which will shoot mail after crossing threshold limit Please suggest. Regards Manoj (1 Reply)
Discussion started by: manoj.solaris
1 Replies

3. Shell Programming and Scripting

Disk Space

Hi Guys i have a nice little piece of code then i need to modify so that is does not look at /Voulmes/* thanks sub disk_full { my $i = 0; open( DF, "df -l|" ); while (<DF>) { #chomp(); next if (/^\/proc\b/); $i++; next if ( $i == 1 ); ... (3 Replies)
Discussion started by: ab52
3 Replies

4. Red Hat

disk space

when i check /export directory of my machine gets filled up (85%) i removed some old logs. but after cleaning df -k command still shows that /export is still 85% full. Is there a way to force df to reflect actual free space without rebooting? My machine is a production one and can't... (8 Replies)
Discussion started by: aboorkuma
8 Replies

5. Shell Programming and Scripting

Disk Space

Hi This is my script for disk space monitoring clear if then echo "You must be root user to execute the script" fi ALERT_LEVEL=10 CONSUMPTION_LEVEL= `df -k | awk {'print $5'} | cut -d '%' -f1 | sed "1 d"` for i in $CONSUMPTION_LEVEL do FILE_SYSTEM=`df -k | awk {'print $1'} |... (3 Replies)
Discussion started by: chrs0302
3 Replies

6. Filesystems, Disks and Memory

disk space

Hello All- Am new member to this forum. Have some unix experience. But true believer in it compared to windows. Have a question regarding the disk space. I know a command to check the total disk space utilization using: df -k . but what is the command to check the same disk space by... (6 Replies)
Discussion started by: milkyway
6 Replies

7. Filesystems, Disks and Memory

disk space

Hi experts i am new in unix and informix and would like to ask 2 questions 1) my server shows when using df -k fs 1024-block used available /usr 10079072 3668670 6381144 does this mean i have 10GB, and used up 3.7GB and available 6.3GB ??? is... (3 Replies)
Discussion started by: kingsto88
3 Replies

8. Solaris

Disk space?

I'm a Unix newbie running Solaris 9. After installing a fresh copy on a 40GB drive I noticed the available disk space is 2% free or approximately 200MB available. Is that possible? Did I do something wrong? (4 Replies)
Discussion started by: jbarbuto
4 Replies

9. UNIX for Dummies Questions & Answers

available disk space on disk device???

Hello, Can someone please tell me which command to use to determine the available disk space on a given disk device? I have to write a shell script that compresses files and stores them in a specific location but I am not sure how "conservative" I should be? Thanks in advance! Al. (4 Replies)
Discussion started by: alan
4 Replies
Login or Register to Ask a Question