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.

This command:

$ time (\ls /path/to/lots/of/dir*/*/*/*.ext > inputs.txt )

real    1m9.064s
user    1m3.265s
sys     0m5.993s

Gives me a huge list of file names inside the file "inputs.txt".

I need to know the total size of all files described in inputs.txt, preferably without list all of them.

share|improve this question

1 Answer 1

You need to use the option -c of du:

du -csh /path/to/lots/of/dir*/*/*/*.ext

To show only the final count, you can use tail -n 1:

du -csh /path/to/lots/of/dir*/*/*/*.ext | tail -n 1
share|improve this answer
This only works if the filenames do not contain spaces. –  jordanm Jan 9 at 20:11
Shouldn't the \ls be removed? –  John1024 Jan 9 at 20:53
Did you mean du -csh /path/to/lots/of/dir*/*/*/*.ext? Or du -csh $(cat inputs.txt) (which only works if there are no special characters in file names)? What's \ls doing here? –  Gilles Jan 9 at 22:47
Yes! Thanks by the correction, it was a typo error –  RSFalcon7 Jan 10 at 11:44

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.