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.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityHow 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.
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.
What doesn't work from your example? Do you want a sum?
man du
shows that the -c
option provides a sum of usage:
du -sc *.sql
You may also like the -h
or -k
arguments.
Your question is very ambiguous but I suspect you are looking for the -c
flag to produce a total.
du -c *.sql
du -s dir
. Which will summarize disk usage of the directory, and nothing else.
– Elazar Leibovich
May 23 '11 at 13:44
can be a variation like:
du -sch * | tail -n 1
du -c * | tail -n 1
. Also the -s
option doesn't do anything here.
– Wildcard
Dec 22 '15 at 4:44
-h
option is not called for; the OP didn't ask for it. | tail -n 1
is better than | grep total
because there might be files whose names contain the word total
.
– G-Man Says 'Reinstate Monica'
Dec 22 '15 at 4:46
-s
decreases the amount of data being written through the pipe (if any of the argument(s) are directories).
– G-Man Says 'Reinstate Monica'
Dec 22 '15 at 4:48
cat *.sql | wc -c
Answer is in bytes.