-4

How can I print out the amount of diskspace that a particular user is consuming in their home directory with files? I want to print out each file and its size in K and then at the end print out a grand total of diskspace used in K as well.

kellyS723
  • 31
  • 8
  • 1
    I'm voting to close this question as off-topic because it belongs to Linux & Unix or Ubuntu StackExchange. – Ely Jun 17 '16 at 01:31

1 Answers1

2

This should do the job:

du -a -k ~/

From the manpage man du,

-a, --all
write counts for all files, not just directories
-k
like --block-size=1K

The "grand total of diskspace used in K" will automatically be displayed on the last line.

For directories with many items, or to simply speed-up the result and suppress stdout output, add a pipe to tail to show only the resulting last line, and use optional -h flag for 'human-readable' display:

du -h ~/ | tail -n 1
15G /home/david/