See the size of a directory in your terminal
Say you quickly want to check the size of your current directory, in a human readable way. We can easily check that out using the du
command. Per the UNIX man page, du
's purpose is to "estimate file space usage". If we add the -s
flag, which prints a summary (rather than stats for individual files) and the -h
flag, which prints sizes in a human readable format (ex. 1K, 234M, or 4.8G), we get a wonderful output
$ du -sh
19M .
The du
command takes files and folders as arguments, and will use the current directory as the target if none is specified. This means that you can see the size of a certain file or directory if you'd like
$ ls
Gemfile app.rb
$ du -sh Gemfile
4.0K Gemfile
Written by Jack Weiss
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#