[{"data":1,"prerenderedAt":119},["ShallowReactive",2],{"blog-post-ripgrep-replace-text-in-files":3,"recent-posts":74},{"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},"awgi0RIAACYAhiZv","ripgrep-replace-text-in-files",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+%22awgi0RIAACYAhiZv%22%29+%5D%5D",[],"2026-12-04T22:45:44+0000",[12],"how-to-replace-text-in-files-with-ripgrep-and-sed",[],"en-us",[],{"title":17,"date":23,"description":24,"image":29,"content":40},[18],{"type":19,"text":20,"spans":21,"direction":22},"heading1","How to Replace Text in Files with Ripgrep and Sed",[],"ltr","2026-12-04",[25],{"type":26,"text":27,"spans":28,"direction":22},"heading2","Learn how to find and replace text in many files with ripgrep (rg) and sed",[],{"dimensions":30,"alt":33,"copyright":6,"url":34,"id":35,"edit":36},{"width":31,"height":32},1280,720,"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":37,"y":37,"zoom":38,"background":39},0,1,"transparent",[41,45,49,52,55,58,61,64,67,71],{"type":42,"text":43,"spans":44,"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":46,"text":47,"spans":48,"direction":22},"preformatted","brew install ripgrep",[],{"type":42,"text":50,"spans":51,"direction":22},"First, open your terminal and navigate to your project folder. Before you change anything, preview the result with ripgrep's \u003Ccode>-r\u003C\u002Fcode> flag:",[],{"type":46,"text":53,"spans":54,"direction":22},"rg 'old_text' -r 'new_text'",[],{"type":42,"text":56,"spans":57,"direction":22},"The \u003Ccode>-r\u003C\u002Fcode> flag only changes what ripgrep prints, so your files stay exactly the same. When it looks right, run this to replace the text in every file:",[],{"type":46,"text":59,"spans":60,"direction":22},"rg -l -0 'old_text' | xargs -0 sed -i '' 's\u002Fold_text\u002Fnew_text\u002Fg'",[],{"type":42,"text":62,"spans":63,"direction":22},"Just replace \u003Ccode>old_text\u003C\u002Fcode> and \u003Ccode>new_text\u003C\u002Fcode> with your own text. \u003Ccode>-l\u003C\u002Fcode> lists only the matching file names, \u003Ccode>-0\u003C\u002Fcode> keeps names with spaces safe, and \u003Ccode>xargs -0\u003C\u002Fcode> hands them to \u003Ccode>sed\u003C\u002Fcode>. Don't worry if it prints nothing; that's normal.",[],{"type":42,"text":65,"spans":66,"direction":22},"On a Mac, the two single quotes after \u003Ccode>-i\u003C\u002Fcode> matter. If you copy the Linux version, \u003Ccode>sed -i 's\u002F…\u002Fg'\u003C\u002Fcode>, you'll get \u003Ccode>unescaped newline inside substitute pattern\u003C\u002Fcode> and nothing changes. To check the result, run \u003Ccode>rg 'new_text'\u003C\u002Fcode>.",[],{"type":68,"oembed":69},"embed",{"embed_url":70,"type":68},"",{"type":42,"text":72,"spans":73,"direction":22},"If your text contains slashes, like a URL, use \u003Ccode>|\u003C\u002Fcode> as the delimiter: \u003Ccode>'s|http:\u002F\u002Fold|https:\u002F\u002Fnew|g'\u003C\u002Fcode>. For whole words, swap \u003Ccode>sed -i ''\u003C\u002Fcode> for \u003Ccode>perl -pi -e\u003C\u002Fcode> and use \u003Ccode>\\b\u003C\u002Fcode>, because macOS \u003Ccode>sed\u003C\u002Fcode> doesn't support it.",[],{"results":75,"page":38,"results_per_page":117,"results_size":117,"total_results_size":118,"total_pages":38},[76,78,97],{"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":77},{"image":29,"title":17},{"id":79,"uid":80,"url":6,"type":7,"href":81,"tags":82,"first_publication_date":10,"last_publication_date":10,"slugs":83,"linked_documents":85,"lang":14,"alternate_languages":86,"data":87},"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",[],[84],"ripgrep-how-to-search-case-insensitive",[],[],{"image":88,"title":94},{"dimensions":89,"alt":90,"copyright":6,"url":91,"id":92,"edit":93},{"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":37,"y":37,"zoom":38,"background":39},[95],{"type":19,"text":90,"spans":96,"direction":22},[],{"id":98,"uid":99,"url":6,"type":7,"href":100,"tags":101,"first_publication_date":10,"last_publication_date":10,"slugs":102,"linked_documents":104,"lang":14,"alternate_languages":105,"data":106},"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",[],[103],"how-to-use-jq-with-curl",[],[],{"image":107,"title":113},{"dimensions":108,"alt":109,"copyright":6,"url":110,"id":111,"edit":112},{"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":37,"y":37,"zoom":38,"background":39},[114],{"type":19,"text":115,"spans":116,"direction":22},"How to Use 'jq' with 'curl'",[],3,137,1796424369380]