Quickly find the largest files in a directory
From the Terminal, if you want to quickly find out what the largest files are in a directory, try this variation of the ls command:
ls -lShr
the l flag will display the items in a list, the S flag sorts by size, and h makes it readable in MB/GB (human readable), with r reversing the report order so that the largest file is the last on the list and thus right above the returned command prompt.
If you want the largest file in a directory of a certain type, simply specify the file type with a wildcard to show all files fitting that description:
ls -lShr *.zip
Try it out with any filetype *.mp3 *.mov *.wmv *.psd , etc
You may also want to check out the bigfiles command line tool to get the largest files within a given directory:
bigfiles -h
time -p bigfiles -n 40 ~/
see: http://codesnippets.joyent.com/posts/show/1888
$ du -xak ~/ 2> /dev/null | sort -nr | head -n 40
will list the 40 heaviest files in your home directory
[…] OS X Daily posted a tip on how to find the largest file in a directory. I have my own that uses the du UNIX utility. The du utility displays the file system usage statistics for each file and directory argument. To use it, type du in a Terminal window. The first column of output is the number of bytes and the second column is the directory path and file. If you run this utility in a directory with lots of files a lot of stuff will scroll off the screen. Not very useful. […]
[…] OS X Daily posted a tip on how to find the largest file in a directory. I have my own that uses the du UNIX utility. The du utility displays the file system usage statistics for each file and directory argument. To use it, type du in a Terminal window. The first column of output is the number of bytes and the second column is the directory path and file. If you run this utility in a directory with lots of files a lot of stuff will scroll off the screen. Not very useful. […]