Find The Size Of A Folder Within Terminal 0

Terminal

Share
Find The Size Of A Folder Within Terminal

Hey,

If you use Terminal a lot, or find yourself deep within your system you may want to find the size of a folder or file within the Terminal window. This can be done with a simple command. It allows you to find the size, which you can then use to work out if you have the right folder, or if it is going to beneficial to transfer the files over your network. This simple command allows you to output the size in a human readable format, so it will tell you if the size is in megabytes, gigabytes or a different size.

To use this command simply type the following into Terminal:

du -sh */

This will run the du command, which will find the size. The important parts of this command is the -s appendix, which gives only the top level of sizes, without this command it will give you every file and folder and it size, not that useful. The second important command is the */. This tells the command to run in the current folder only.

You can modify this command to give the output in megabytes using the following:

du -sm */

Gigabytes can be done with, -g, kilobytes with, -k.

You can also search for the size of other folders by specifying the path. For example, if you want to find the size of your downloads folder of the folder you are in you would type the following:

du -sh ./downloads

You can also specify paths with the following:

du -sh /long/path/to/folder

It is only a simple command, but useful if you work with Terminal frequently one that useful. It is also on command I frequently forget.

If you want to find out more about Terminal I recommend Mac OS X Unix Toolbox Book and Macintosh Terminal Pocket Guide. If you have any questions, please leave a comment.


If you want to keep up with the latests post from Mac Tricks And Tips I recommend you subscribe to the RSS Feed.

Where To Next?

  • Subscribe To Mac Tricks And Tips