by mnaydin · 9y ago · 0 comments
find /path/to/dir -type f -printf "%s\n" | awk ' { s += $0 } END { print s " bytes" } '
The find command has much powerful file filtering capabilities than that of the ls command and works better with weird characters in filenames.
There is also the -print0 option to find to handle filenames with newlines in them.
-print0 may be non-POSIX and a GNU extension.
POSIX has -print, but interestingly, in some Unixes I have seen that not using -print still prints the filenames found, by default.
If no expression is present, -print shall be used as the expression. Otherwise, if the given expression does not contain any of the primaries -exec, -ok, or -print, the given expression shall be effectively replaced by: ( given_expression ) -print
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/fi...