Operating System - Linux
1752726 Members
5525 Online
108789 Solutions
New Discussion юеВ

Space used by files and find command

 
SOLVED
Go to solution
Leo The Cat
Regular Advisor

Space used by files and find command

Hi Guys

How to have the space size used by files matching the result of the find . -name core* command.

Bests Regards
Den
4 REPLIES 4
Ivan Ferreira
Honored Contributor
Solution

Re: Space used by files and find command

You can use something like this:

find . -type f -name "*core*" -ls 2> /dev/null | awk -v SUM=0 '{SUM=SUM+$7} END {print "Total:",SUM}'
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Leo The Cat
Regular Advisor

Re: Space used by files and find command

Thanks, after a small adaptation this affair works correclty.

A small question, why the 2> /dev/null in this context ?


Thanks again Ivan
Bests Regards
Den
Ivan Ferreira
Honored Contributor

Re: Space used by files and find command

Is only to avoid messages like "permission denied" errors on the output.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Leo The Cat
Regular Advisor

Re: Space used by files and find command

Hi Ivan

And thanks again on this thread.

Bests Regards
Den