Take the 2-minute tour ×
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
add comment

4 Answers

up vote 5 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
add comment

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
add comment

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
add comment
cat *.sql | wc -c

Answer is in bytes.

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

Your Answer

 
discard

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.