<commit_before><commit_msg>adding a tip for finding huge files on macos<commit_after>---
layout: post
title:  "Huge files are eating my disk, where are they?"
date:   2017-11-27 21:00:00 +1300
categories: du disk software file size
---

# Problem

Recently I have had some concerns about the amount of disk being used by my macbook pro; at times it'll range from 40Gb total disk used to 100Gb total disk used.

I'm not keen on investing in a proprietary tool to do something fairly straightforward, so I decided to use a built-in function: `du`.

# Finding all large files for a given directory

This solution uses `du`, a disk usage utility packaged with macos.

Example for finding all files greater than 1G: `du -h ~/ | grep 'G       '`

If the above command doesn't limit your results to only files greater than 1G and instead gives all results with G in the file path, simply change the amount of space after G (it's variable depending on your choice of shell format).

# Find all files in a tree structure greater than a certain size

Example for finding all files greater than 1G: `tree -h | grep G]`

# More

Need to find smaller files? Use B, K or M instead of G.

Tip: `-h` also works for `ls`. For example, try: `ls -Shl` (S provides order of largest at top).
{'fraction_non_alphanumeric': 0.06456692913385827, 'fraction_numerical': 0.02047244094488189, 'mean_word_length': 3.7781954887218046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2870514', 'n_tokens_mistral': 375, 'n_tokens_neox': 345, 'n_words': 215}