문제

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

도움이 되었습니까?

해결책

How about

du -ch abc_* | tail -n 1

That should produce a grand total.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top