Getting size with du of files only
I usually use the -exec
utility. Like this:
find . -type f -exec du -a {} +
I tried it both on bash and ksh with GNU find. I never tried AIX, but I'm sure your version of find has some -exec
syntax.
The following snippet sorts the list, largest first:
find . -type f -exec du -a {} + | sort -n -r | less
If you have GNU utilities, try
find . -type f -print0 | du --files0-from=-
I generally use:
find . -type f -print0 | xargs -r0 du -a
Xargs usually calls the command, even if there are no arguments passed; xargs du </dev/null
will still be called, xargs -r du </dev/null
will not call du. The -0
argument looks for null-terminated strings instead of newline terminated.
Then I usually add | awk '{sum+=$1} END {print sum}'
on the end to get the total.