How to Calculating space used in GB for any particular directory in UNIX?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to Calculating space used in GB for any particular directory in UNIX?
# 1  
Old 04-25-2013
How to Calculating space used in GB for any particular directory in UNIX?

How to Calculating space used in GB for any particular directory in unix



Currently I am using : df -h which gives me space for each mout point

Code:
ldndyn1:/vol/v01/dyn/sbcexp/dyn
                      1.1T  999G   29G  98% /sbcimp/dyn


but I need for some internal particular directory size eg: directory/folder is DIR_A:

Currently I am trying with below command:
Code:
du DIR_A  |awk '{sum +=$1} END {print sum}'

it giving me output as : which I am thinking in bytes?
Code:
31758932



Please advise on best approch

Last edited by Franklin52; 04-25-2013 at 06:57 AM.. Reason: Please use code tags
# 2  
Old 04-25-2013
try below one:
Code:
du -g DIR_A |awk '{sum +=$1} END {print sum}'

or
Code:
du -h DIR_A |awk '{sum +=$1} END {print sum}'


Last edited by Franklin52; 04-25-2013 at 06:58 AM.. Reason: Please use code tags
# 3  
Old 04-25-2013
not think that help
*
My is Linux:
_____________________________________
Code:
$ du -h  DIR_A/
40M     DIR_A/CDC
1.6M    DIR_A/DQI/dqiadhoc-431
du: cannot read directory `DIR_A/DQI/dqi_lem-8718/lem-8718/.svn': Permission denied
52K     DIR_A/DQI/dqi_lem-8718/lem-8718
56K     DIR_A/DQI/dqi_lem-8718
1.7M    DIR_A/DQI
248M    DIR_A/

__________________________________________________________________________
Code:
$ du -h DIR_A '{sum +=$1} END {print sum}'
du: cannot read directory `DIR_A/DQI/dqi_lem-8718/lem-8718/.svn': Permission denied
399.3


Last edited by Franklin52; 04-25-2013 at 07:18 AM.. Reason: Please use code tags
# 4  
Old 04-25-2013
It means what it says, it doesn't have permission to access that directory. If that directory's not important, you can ignore that error.

To get a sum of one particular directory, du -hs /path/to/folder 2>/dev/null The -s means 'summary', instead of listing folders inside.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

Calculating total space in GB for all files with typical pattern

Hi Experts, In a particular dir, I have many files *AJAY*. How can I get total size of all such files. I tried du -hs *AJAY* but it gave me individual size of all files. All I require is summation of all. Thanks, Ajay (4 Replies)
Discussion started by: ajaypatil_am
4 Replies

2. Shell Programming and Scripting

Calculating server space

I am Connected With 4 servers I want to check the free space available in each server HOW to do this ? (8 Replies)
Discussion started by: pranabrana
8 Replies

3. Shell Programming and Scripting

Calculating server space

I am Connected With 4 servers I want to check the free space available in each server HOW to do this ? Edit/Delete Message (3 Replies)
Discussion started by: pranabrana
3 Replies

4. Filesystems, Disks and Memory

calculating the filesystem space

Hi, Just wanted to confirm that what Im doing is correct to calculate the space allocated to filesystem: >df -k . Filesystem 1024-blocks Free %Used Iused %Iused Mounted on /test 48720000 9337904 81% 14846 1% /home The space allocated = 48720000/1024 =... (1 Reply)
Discussion started by: deepakgang
1 Replies

5. UNIX for Dummies Questions & Answers

How to find the free space & usage of the particular directory in Hp-Unix?

How to find the free space & usage of the particular directory in Hp-Unix? I want to see the usage in % (2 Replies)
Discussion started by: bobprabhu
2 Replies

6. Filesystems, Disks and Memory

Calculating Drive Space Increase

I trying to calculate drive space with RAID. I know the equation is: (n-1)/n * drive capacity but, when I use that my calculations don't come out when I compare to what I already know exists: I have 3 - 18.2gb SCSI drives that contain two logical drives C & D. Using the math, (3-1)/3 * 18.2... (1 Reply)
Discussion started by: JTalbot017
1 Replies

7. Filesystems, Disks and Memory

calculating disk space for growth

what's the best way to calculate the raw disk space in format. the system is a Solaris system using EMC disks- df -k will give me what's used plus available.Now I need the total disk space that the system is using/assigned. Which means I must inventory the raw disks in format. the system uses... (6 Replies)
Discussion started by: sholiver
6 Replies

8. Shell Programming and Scripting

Scripts for calculating size and remaining space of a directory automatically.

I would like to create a script for calculating size and remaining space of a directory automatically every 24 hours, then send an email to report to the admin. * POSIX and PERL are preferred. Can anyone help, please? (1 Reply)
Discussion started by: leonall
1 Replies

9. Filesystems, Disks and Memory

Calculating Disc Space

Ok.... Can someone please point me in the right direction. I simply want to know how to take the results of a dfspace or df command and be able to know how to determine how much disk space is either used or remaining. 1$ dfspace Filesystem 512-blocks Free %Used Iused %Iused Mounted... (5 Replies)
Discussion started by: Docboyeee
5 Replies

10. UNIX for Dummies Questions & Answers

Calculating Disc Space

I need some help in determining disc space. I ran the following commands on my IBM RS6000 server and this is what I get # dfspace Filesystem 512-blocks Free %Used Iused %Iused Mounted on /dev/hd4 32768 19832 40% 1225 15% / /dev/hd2 802816 277256 66% ... (2 Replies)
Discussion started by: Docboyeee
2 Replies
Login or Register to Ask a Question