0

I am trying to get the disk usage of all the files present in a particular directory using the following commands and I am getting different answers for both. Could anyone explain why?

find ./ -type f -name '*.*' -exec du -csh {} + | grep total$
83M total

find ./ -type f -exec du -csh {} + | grep total$
101M total
38M  total

1 Answer 1

0

Most likely you have files that don't match *.*.

Try

find . -type f ! -name '*.*'
3
  • Thanks for the answer. Could you also explain why there are two values in the second case ?
    – Stuti
    Sep 6, 2018 at 21:39
  • @Stuti It should be clear from running your pipeline without the final grep part.
    – Kusalananda
    Sep 6, 2018 at 21:55
  • There are two result lines because there are too many names for one invocation of du, it is split in two.
    – RalfFriedl
    Sep 7, 2018 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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