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.
Asked
Active
Viewed 51 times
1 Answers
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/

chickity china chinese chicken
- 7,709
- 2
- 20
- 49