Here is a solution with [POSIX ls][y]:

<!-- language: lang-lua -->

 ls -ARn dir | awk '{z += $5} END {print z}'

http://unix.stackexchange.com/q/16640/#321502

[y]:http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html