Try:
find . -name "*.undo" -ls | awk '{total += $7} END {print total}'
On my system the size of the file is the seventh field in the find -ls
output. If your find … -ls
output is different, adjust.
In this version, using the existing directory information (file size) and the built-in ls feature of find should be efficient, avoiding process creations or file i/o.