Category filter
Script to Find File/Folder size on Mac
Have you ever wondered how big a specific file or folder on a Mac is? You can view the file or folder size using the Get Info option by right-clicking on the required file or folder on a Mac. However, manually checking the file or folder size on multiple endpoints may be tiresome for the admins. Now, IT admins can remotely fetch device details like file or folder size by running a custom script on the endpoint devices using Hexnode UEM. This doc includes the Terminal commands to retrieve the file or folder size on macOS devices.
Scripting Language – Bash
File extension – .sh
Find file size
1 2 |
#!/bin/bash du –h ‘file name with extension’ |
For example: du –h document.txt
The du
command is a standard command that allows users to gain disk usage information quickly. Some of the options supported with the command are
-h
flag prints size outputs in Byte format, this provides a unit of measure.-a
command lists the sizes of all files and directories in the given file path.- For example –
du –a ~/Downloads/Wallpapers
-c
flag adds a line to the bottom of the output that displays the grand total of all the disk usage for the file or folder path given.- For example –
du –c ~/Downloads