Question

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

Was it helpful?

Solution

How about

du -ch abc_* | tail -n 1

That should produce a grand total.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top