<commit_before># Filtering

1.  You already saw how to generate a hit count for an entire
    directory structure:

        $ grep -cri "search" .

    The output is unsorted, and includes files with no hits:

        filter.md:0
        inspect.md:4<commit_msg>thx_luke<commit_after># Filtering

1.  In the previous section you saw how to generate a hit count for
    repeated lines within a file. Here's how to do a hit count for
    matches across many files within a directory tree:

        $ grep -cri "search" .

    The dot at the end means to search the current directory.  The
    `-r` searches recursively.  The `-i` matches both upper- and
    lowercase.  The `-c` displays the number of matches rather than
    the contents of the matching line.

    The output is unsorted, and includes files with no hits at all:

        filter.md:0
        inspect.md:4
{'fraction_non_alphanumeric': 0.05753739930955121, 'fraction_numerical': 0.006904487917146145, 'mean_word_length': 2.580246913580247, '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': '4062395', 'n_tokens_mistral': 252, 'n_tokens_neox': 243, 'n_words': 122}