How to sum Linux directory disk allocated

17 December,2019 by Tom Collins

Question: I need to report on the sum of disk allocated for Linux directories dedicated to DB2  LUW directories . How can I sum the directories disk allocated ?

I've tried various procedures but the sums arent't adding  to same totals that are displayed when df - h is printed 

Answer: There's a few different ways of getting to the same total . Here's a simple example of the sum of  disk allocated for two directories. In the example below - I'm adding disk allocated for /mydir and /mydir/logs 

 

df -h /mydir/ /mydir/logs | awk '{ alloc += $1 } END {print alloc}'

 

In this example the directories allocated as static . If the requirement was to do something more dynamic - you'll need to put some extra scripting around this code to drop the directory names in the line

 

Top 10 Yoda tips for the Linux command line

 

 

Author: Rambler(http://www.dba-db2.com)

Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to sum Linux directory disk allocated

Comments are moderated, and will not appear until the author has approved them.


dba-db2.com | DB2 Performance Tuning | DBA DB2:Everything | FAQ | Contact | Copyright