btongeorge
btongeorge

Reputation: 453

Using du to get size of specific sub directories

I'm trying to write a script to summarise a bunch of folders. So I have the following structure:

monitor/abc_123 1G
monitor/abc_213 1G 
monitor/abc_111 2G
monitor/bbc_123 2.5G

What I need is to issue a command (using du I presume) to summarise the directories prefixed with "abc_"

I've tried the following:

du -sh abc*

... but this just gives me a summary for each folder. I need the script to generate the total size of all three directories in this example.

Thanks in advance

Upvotes: 0

Views: 10378

Answers (1)

bitmask
bitmask

Reputation: 34618

How about

du -ch abc_* | tail -n 1

That should produce a grand total.

Upvotes: 3

Related Questions