# How to get file sizes of large files in OS X Terminal?

I'm trying to get the file size of a big file (1GB +) using the OS X Terminal. I'm using du -sh. But also after 30 seconds I don't have any result, is there any faster command?

Thanks.

• Are you trying to get the size of a single file or all files in a given location? – user3439894 May 17 '16 at 12:54
• It's different, sometimes it is a folder, file or application. – HelloToYou May 17 '16 at 12:56
• You don't need the -s option for a single file. du -h <file> will do the job. – jherran May 17 '16 at 12:56
• Try ls -lh filename – fd0 May 17 '16 at 13:35

Say you are looking for big files in your home directory, use this command:

find ~ -size +1G


Replace ~ with the directory of interest.

# Update

My original response was wrong, but I'll keep it to remind myself. If you are trying to get the size of a file, try this:

stat -f '%z' filename  # Normal file
stat -L -f '%z' filename  # symbolic link file


I have not figure out how to do it for a directory yet.

• The z option list the total number of bytes used in the file but not the total blocks allocated to the file. To get the total allocated size of a file in bytes you could do something like echo "$(($(stat -f'%b' filename) * 512 ))" – fd0 May 17 '16 at 14:20

You can use the following command

$sudo find / -type f -size +1G In case you want to avoid traversing mounted drives, your command should be:$ sudo find -x / -type f -size +1G