Skip to main content
added 96 characters in body
Source Link
Josh Hunt
  • 21.3k
  • 20
  • 85
  • 124

Although it does not give you a nested output like that, try du

du -h /path/to/dir/

Running that on my Documents folder spits out the following:

josh-hunts-macbook:Documents joshhunt$ du -h
  0B    ./Adobe Scripts
  0B    ./Colloquy Transcripts
 23M    ./Electronic Arts/The Sims 3/Custom Music
  0B    ./Electronic Arts/The Sims 3/InstalledWorlds
364K    ./Electronic Arts/The Sims 3/Library
 77M    ./Electronic Arts/The Sims 3/Recorded Videos
101M    ./Electronic Arts/The Sims 3/Saves
 40M    ./Electronic Arts/The Sims 3/Screenshots
1.6M    ./Electronic Arts/The Sims 3/Thumbnails
387M    ./Electronic Arts/The Sims 3
387M    ./Electronic Arts
984K    ./English Advanced/Documents
1.8M    ./English Advanced
  0B    ./English Extension/Documents
212K    ./English Extension
100K    ./English Tutoring
5.6M    ./IPT/Multimedia Assessment Task
720K    ./IPT/Transaction Processing Systems
8.6M    ./IPT
1.5M    ./Job
432K    ./Legal Studies/Crime
8.0K    ./Legal Studies/Documents
144K    ./Legal Studies/Family/PDFs
692K    ./Legal Studies/Family
1.1M    ./Legal Studies
380K    ./Maths/Assessment Task 1
388K    ./Maths
[...]

Then you can sort the output by piping it through to sort

du /path/to/dir | sort -n

Although it does not give you a nested output like that, try du

du -h /path/to/dir/

Running that on my Documents folder spits out the following:

josh-hunts-macbook:Documents joshhunt$ du -h
  0B    ./Adobe Scripts
  0B    ./Colloquy Transcripts
 23M    ./Electronic Arts/The Sims 3/Custom Music
  0B    ./Electronic Arts/The Sims 3/InstalledWorlds
364K    ./Electronic Arts/The Sims 3/Library
 77M    ./Electronic Arts/The Sims 3/Recorded Videos
101M    ./Electronic Arts/The Sims 3/Saves
 40M    ./Electronic Arts/The Sims 3/Screenshots
1.6M    ./Electronic Arts/The Sims 3/Thumbnails
387M    ./Electronic Arts/The Sims 3
387M    ./Electronic Arts
984K    ./English Advanced/Documents
1.8M    ./English Advanced
  0B    ./English Extension/Documents
212K    ./English Extension
100K    ./English Tutoring
5.6M    ./IPT/Multimedia Assessment Task
720K    ./IPT/Transaction Processing Systems
8.6M    ./IPT
1.5M    ./Job
432K    ./Legal Studies/Crime
8.0K    ./Legal Studies/Documents
144K    ./Legal Studies/Family/PDFs
692K    ./Legal Studies/Family
1.1M    ./Legal Studies
380K    ./Maths/Assessment Task 1
388K    ./Maths
[...]

Although it does not give you a nested output like that, try du

du -h /path/to/dir/

Running that on my Documents folder spits out the following:

josh-hunts-macbook:Documents joshhunt$ du -h
  0B    ./Adobe Scripts
  0B    ./Colloquy Transcripts
 23M    ./Electronic Arts/The Sims 3/Custom Music
  0B    ./Electronic Arts/The Sims 3/InstalledWorlds
364K    ./Electronic Arts/The Sims 3/Library
 77M    ./Electronic Arts/The Sims 3/Recorded Videos
101M    ./Electronic Arts/The Sims 3/Saves
 40M    ./Electronic Arts/The Sims 3/Screenshots
1.6M    ./Electronic Arts/The Sims 3/Thumbnails
387M    ./Electronic Arts/The Sims 3
387M    ./Electronic Arts
984K    ./English Advanced/Documents
1.8M    ./English Advanced
  0B    ./English Extension/Documents
212K    ./English Extension
100K    ./English Tutoring
5.6M    ./IPT/Multimedia Assessment Task
720K    ./IPT/Transaction Processing Systems
8.6M    ./IPT
1.5M    ./Job
432K    ./Legal Studies/Crime
8.0K    ./Legal Studies/Documents
144K    ./Legal Studies/Family/PDFs
692K    ./Legal Studies/Family
1.1M    ./Legal Studies
380K    ./Maths/Assessment Task 1
388K    ./Maths
[...]

Then you can sort the output by piping it through to sort

du /path/to/dir | sort -n
added 1118 characters in body
Source Link
Josh Hunt
  • 21.3k
  • 20
  • 85
  • 124

Although it does not give you a nested output like that, try du

du -h /path/to/dir/

Running that on my Documents folder spits out the following:

josh-hunts-macbook:Documents joshhunt$ du -h
  0B    ./Adobe Scripts
  0B    ./Colloquy Transcripts
 23M    ./Electronic Arts/The Sims 3/Custom Music
  0B    ./Electronic Arts/The Sims 3/InstalledWorlds
364K    ./Electronic Arts/The Sims 3/Library
 77M    ./Electronic Arts/The Sims 3/Recorded Videos
101M    ./Electronic Arts/The Sims 3/Saves
 40M    ./Electronic Arts/The Sims 3/Screenshots
1.6M    ./Electronic Arts/The Sims 3/Thumbnails
387M    ./Electronic Arts/The Sims 3
387M    ./Electronic Arts
984K    ./English Advanced/Documents
1.8M    ./English Advanced
  0B    ./English Extension/Documents
212K    ./English Extension
100K    ./English Tutoring
5.6M    ./IPT/Multimedia Assessment Task
720K    ./IPT/Transaction Processing Systems
8.6M    ./IPT
1.5M    ./Job
432K    ./Legal Studies/Crime
8.0K    ./Legal Studies/Documents
144K    ./Legal Studies/Family/PDFs
692K    ./Legal Studies/Family
1.1M    ./Legal Studies
380K    ./Maths/Assessment Task 1
388K    ./Maths
[...]

Although it does not give you a nested output like that, try du

du -h /path/to/dir/

Although it does not give you a nested output like that, try du

du -h /path/to/dir/

Running that on my Documents folder spits out the following:

josh-hunts-macbook:Documents joshhunt$ du -h
  0B    ./Adobe Scripts
  0B    ./Colloquy Transcripts
 23M    ./Electronic Arts/The Sims 3/Custom Music
  0B    ./Electronic Arts/The Sims 3/InstalledWorlds
364K    ./Electronic Arts/The Sims 3/Library
 77M    ./Electronic Arts/The Sims 3/Recorded Videos
101M    ./Electronic Arts/The Sims 3/Saves
 40M    ./Electronic Arts/The Sims 3/Screenshots
1.6M    ./Electronic Arts/The Sims 3/Thumbnails
387M    ./Electronic Arts/The Sims 3
387M    ./Electronic Arts
984K    ./English Advanced/Documents
1.8M    ./English Advanced
  0B    ./English Extension/Documents
212K    ./English Extension
100K    ./English Tutoring
5.6M    ./IPT/Multimedia Assessment Task
720K    ./IPT/Transaction Processing Systems
8.6M    ./IPT
1.5M    ./Job
432K    ./Legal Studies/Crime
8.0K    ./Legal Studies/Documents
144K    ./Legal Studies/Family/PDFs
692K    ./Legal Studies/Family
1.1M    ./Legal Studies
380K    ./Maths/Assessment Task 1
388K    ./Maths
[...]
Source Link
Josh Hunt
  • 21.3k
  • 20
  • 85
  • 124

Although it does not give you a nested output like that, try du

du -h /path/to/dir/