Disk Usage in Shell

Level 232 keystrokes

du shows disk usage, sorted by size to find large directories.

Shell code

# du -sh *: total size of each item in the current directory, in readable units (e.g. 1.5G)
# sort -rh orders sizes like 1.5G > 256M (largest first); head keeps the top 10
1du -sh * | sort -rh | head -n 10

Output

1.5G	node_modules
256M	dist
128M	src
64M	public
32M	tests
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Shell code and how often they appear.

  • -× 3
  • |× 2
  • *× 1

More Shell examples at level 2

← Shell typing practice