{"id":550,"date":"2015-08-12T10:34:58","date_gmt":"2015-08-12T07:34:58","guid":{"rendered":"http:\/\/www.ersinakyuz.com\/?p=550"},"modified":"2015-08-12T10:34:58","modified_gmt":"2015-08-12T07:34:58","slug":"replace-a-string-in-multiple-files-in-linux-using-grep-and-sed","status":"publish","type":"post","link":"https:\/\/www.ersinakyuz.com\/?p=550","title":{"rendered":"Replace a String in Multiple Files in Linux Using Grep and Sed"},"content":{"rendered":"<h5>Example<\/h5>\n<pre lang=\"bash\" class=\"\">grep -rl 'old-string' .\/ | xargs sed -i 's\/old-string\/new-string\/g'\r\n<\/pre>\n<p>This will search for the string &#8216;old-string&#8217; in all files relative to the current directory and replace &#8216;old-string&#8217; with &#8216;new-string&#8217; for each occurrence of the string in each file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Example grep -rl &#8216;old-string&#8217; .\/ | xargs sed -i &#8216;s\/old-string\/new-string\/g&#8217; This will search for the string &#8216;old-string&#8217; in all files relative to the current directory and replace &#8216;old-string&#8217; with &#8216;new-string&#8217; for each occurrence of the string in each file.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-550","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=\/wp\/v2\/posts\/550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=550"}],"version-history":[{"count":1,"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=\/wp\/v2\/posts\/550\/revisions"}],"predecessor-version":[{"id":551,"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=\/wp\/v2\/posts\/550\/revisions\/551"}],"wp:attachment":[{"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ersinakyuz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}