Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

How can I find how much disk does a list of files uses? I'm looking for a variation of

du -s *.sql

I want to see only the grand total, and with the command above, it always shows a line for each file.

share|improve this question

4 Answers 4

up vote 6 down vote accepted

You can use tail to cut the last line (the total) from the output of du:

du -c *.sql | tail -n 1

There seems to be no way to make du itself report just the total of a set of files.

share|improve this answer

What doesn't work from your example? Do you want a sum? man du shows that the -c argument provides a sum of usage:

du -sc *.sql

You may also like the -h or -k arguments.

share|improve this answer
See my clarification. I want it to print only the sum. – Elazar Leibovich May 23 '11 at 13:41

Your question is very ambiguous but I suspect you are looking for the -c flag to produce a total.

du -c *.sql
share|improve this answer
I want it to have the same effect as du -s dir. Which will summarize disk usage of the directory, and nothing else. – Elazar Leibovich May 23 '11 at 13:44
cat *.sql | wc -c

Answer is in bytes.

share|improve this answer
Yeah, but you need to read the whole whopping 10Gb in order to tell it... – Elazar Leibovich May 26 '11 at 4:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.