[{"data":1,"prerenderedAt":140},["ShallowReactive",2],{"blog-post-ripgrep-count-matches":3,"recent-posts":76},{"id":4,"uid":5,"url":6,"type":7,"href":8,"tags":9,"first_publication_date":10,"last_publication_date":10,"slugs":11,"linked_documents":13,"lang":14,"alternate_languages":15,"data":16},"awbJcRIAACgAJT6a","ripgrep-count-matches",null,"blog_posts","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=axNCmBMAACwA2vJJ&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22awbJcRIAACgAJT6a%22%29+%5D%5D",[],"2026-12-03T22:46:13+0000",[12],"ripgrep-how-to-count-matches",[],"en-us",[],{"title":17,"date":23,"description":24,"image":29,"content":39},[18],{"type":19,"text":20,"spans":21,"direction":22},"heading1","Ripgrep: How to Count Matches",[],"ltr","2026-12-03",[25],{"type":26,"text":27,"spans":28,"direction":22},"heading2","Learn how to count matches per file and in total with ripgrep (rg)",[],{"dimensions":30,"alt":20,"copyright":6,"url":33,"id":34,"edit":35},{"width":31,"height":32},1280,720,"https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002FVtxSm7KzNo6AsHUt_ripgrep-count-matches.png?auto=format,compress","VtxSm7KzNo6AsHUt",{"x":36,"y":36,"zoom":37,"background":38},0,1,"transparent",[40,44,48,51,54,57,60,63,66,69,73],{"type":41,"text":42,"spans":43,"direction":22},"paragraph","Before we start, make sure you have ripgrep installed on your computer. On a Mac, you can install it with Homebrew:",[],{"type":45,"text":46,"spans":47,"direction":22},"preformatted","brew install ripgrep",[],{"type":41,"text":49,"spans":50,"direction":22},"First, open your terminal and navigate to your project folder. To count how many lines match in each file, run:",[],{"type":45,"text":52,"spans":53,"direction":22},"rg -c \"pattern\"",[],{"type":41,"text":55,"spans":56,"direction":22},"You'll get one line per file with the file name and a number. Just keep in mind that \u003Ccode>-c\u003C\u002Fcode> counts matching lines, so a line that contains your word twice only counts once. To count every single occurrence, use \u003Ccode>--count-matches\u003C\u002Fcode> instead:",[],{"type":45,"text":58,"spans":59,"direction":22},"rg --count-matches \"pattern\"",[],{"type":41,"text":61,"spans":62,"direction":22},"Both of these give you counts per file. For one grand total across the whole project, print each match on its own line with \u003Ccode>-o\u003C\u002Fcode> and count the lines with \u003Ccode>wc -l\u003C\u002Fcode>:",[],{"type":45,"text":64,"spans":65,"direction":22},"rg -o \"pattern\" | wc -l",[],{"type":41,"text":67,"spans":68,"direction":22},"This finishes almost instantly, even on big projects, and prints a single number.",[],{"type":70,"oembed":71},"embed",{"embed_url":72,"type":70},"",{"type":41,"text":74,"spans":75,"direction":22},"If you want a full summary, run \u003Ccode>rg -q --stats \"pattern\"\u003C\u002Fcode>. The \u003Ccode>-q\u003C\u002Fcode> flag hides the matching lines, so you only see the total matches, matched lines and files searched.",[],{"results":77,"page":37,"results_per_page":138,"results_size":138,"total_results_size":139,"total_pages":37},[78,99,118],{"id":79,"uid":80,"url":6,"type":7,"href":81,"tags":82,"first_publication_date":83,"last_publication_date":83,"slugs":84,"linked_documents":86,"lang":14,"alternate_languages":87,"data":88},"awgi0RIAACYAhiZv","ripgrep-replace-text-in-files","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=axNCmBMAACwA2vJJ&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22awgi0RIAACYAhiZv%22%29+%5D%5D",[],"2026-12-04T22:45:44+0000",[85],"how-to-replace-text-in-files-with-ripgrep-and-sed",[],[],{"image":89,"title":95},{"dimensions":90,"alt":91,"copyright":6,"url":92,"id":93,"edit":94},{"width":31,"height":32},"Ripgrep: How to Replace Text in Files with Ripgrep and Sed","https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002FOlJ7le5oNEXxcE_I_ripgrep-replace-text-in-files.png?auto=format,compress","OlJ7le5oNEXxcE_I",{"x":36,"y":36,"zoom":37,"background":38},[96],{"type":19,"text":97,"spans":98,"direction":22},"How to Replace Text in Files with Ripgrep and Sed",[],{"id":100,"uid":101,"url":6,"type":7,"href":102,"tags":103,"first_publication_date":83,"last_publication_date":83,"slugs":104,"linked_documents":106,"lang":14,"alternate_languages":107,"data":108},"awgi2hIAACoAhiaF","ripgrep-case-insensitive-search","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=axNCmBMAACwA2vJJ&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22awgi2hIAACoAhiaF%22%29+%5D%5D",[],[105],"ripgrep-how-to-search-case-insensitive",[],[],{"image":109,"title":115},{"dimensions":110,"alt":111,"copyright":6,"url":112,"id":113,"edit":114},{"width":31,"height":32},"Ripgrep: How to Search Case Insensitive","https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002F6H2DfjROfkSO4wel_ripgrep-case-insensitive-search.png?auto=format,compress","6H2DfjROfkSO4wel",{"x":36,"y":36,"zoom":37,"background":38},[116],{"type":19,"text":111,"spans":117,"direction":22},[],{"id":119,"uid":120,"url":6,"type":7,"href":121,"tags":122,"first_publication_date":83,"last_publication_date":83,"slugs":123,"linked_documents":125,"lang":14,"alternate_languages":126,"data":127},"awgi_hIAACoAhibc","jq-use-with-curl","https:\u002F\u002Fmarks-personal-website.cdn.prismic.io\u002Fapi\u002Fv2\u002Fdocuments\u002Fsearch?ref=axNCmBMAACwA2vJJ&q=%5B%5B%3Ad+%3D+at%28document.id%2C+%22awgi_hIAACoAhibc%22%29+%5D%5D",[],[124],"how-to-use-jq-with-curl",[],[],{"image":128,"title":134},{"dimensions":129,"alt":130,"copyright":6,"url":131,"id":132,"edit":133},{"width":31,"height":32},"jq: How to Use jq with curl","https:\u002F\u002Fimages.prismic.io\u002Fmarks-personal-website\u002F3JyqU0cTsv3S-6D0_jq-use-with-curl.png?auto=format,compress","3JyqU0cTsv3S-6D0",{"x":36,"y":36,"zoom":37,"background":38},[135],{"type":19,"text":136,"spans":137,"direction":22},"How to Use 'jq' with 'curl'",[],3,137,1796424369611]