You're on the right path, but use backticks instead of pipe.
du -k `git ls-files` | awk '{total += $1} END {print total}'
If you have to worry about whitespace, both git ls-files
and xargs
can talk in nulls:
git ls-files -z | xargs -0 du -k | awk '{total += $1} END {print total}'
It took so long for you because git ls-files |
was essentially a no-op, and du -k |
was piping output for every file from your current directory down. Exactly what you were trying to avoid!