stillblogging.blogg.se

Mac command line list directory sizes
Mac command line list directory sizes






mac command line list directory sizes

In summary, if you wanted to see how to show the largest files under a directory on MacOS, Unix, and Linux systems, I hope this is helpful. I tried to obtain the size of a directory (containing directories and sub directories) by using the ls command with option l. Their solution was very close, but just needed a minor change or two to work on MacOS. Note: I was pointed towards this solution by this page.

mac command line list directory sizes

In that command, head -30 prints the first 30 results, but then the tail command shows only the last 10 files, which displays files 21-30 in the end. To show files 21-30 you can add in the tail command, like this:ĭu -a * | sort -r -n | head -30 | tail -10 Opening different image files opens up different apps on my Mac and, as the kids say, 'ffs' - I just want to know the image dimensions. Getting information from the shell instead of opening an app, finding a file or directory, etc.what a novel concept. To show the first 20 files/directories you’d use this command: The command line is a gold mine if you come from the perspective of a UI lover. Users/Al/Music> du -a * | sort -r -n | head -10Ĩ049464 iTunes/iTunes Music/Unknown ArtistĦ101880 iTunes/iTunes Music/Unknown Artist/Unknown Album Variations of that `du` commandĪs mentioned, that command shows how to display the largest 10 files and folders under the current OS X directory. In the Music folder on my Mac the command and output look like this: After that, head -10 shows only the first ten lines of output. The Unix/Linux command that worked for me on my MacOS system is this:ĭu is the disk usage command, and the -a flag says, “Display an entry for each file in a file hierarchy.” Then I use the sort command to sort the du output numerically and in reverse. A du/sort command to show the largest files under a directory on Mac OS X Solution: Use the Unix du (disk usage) command, and sort its output. MacOS FAQ: From the command line, how do I show the largest files under a directory on macOS (and Linux/Unix systems).








Mac command line list directory sizes