Let\'s say I want to list all php files in a directory including sub-directories, I can run this in bash:
ls -l $(find. -name *.php -type f)
Here is another way, using du:
find . -name "*.php" -type f -print0 | du -c --files0-from=- | awk 'END{print $1}'
If you want to avoid parsing ls to get the total size, you could say:
find . -type f -name "*.php" -printf "%s\n" | paste -sd+ | bc
I suggest you to firstly search the files and then perform the ls -l (or whatever else). For example like this:
find . -name "*php" -type f -exec ls -l {} \;
and then you can pipe the awk expression to make the addition.