{"id":57,"date":"2010-05-03T01:48:48","date_gmt":"2010-05-02T23:48:48","guid":{"rendered":"https:\/\/it-blog.timk.de\/index.php\/shell-find-and-repleace-string-over-many-files-with-perl"},"modified":"2010-05-03T01:48:48","modified_gmt":"2010-05-02T23:48:48","slug":"shell-find-and-repleace-string-over-many-files-with-perl","status":"publish","type":"post","link":"https:\/\/www.timk.de\/it-blog\/shell-find-and-repleace-string-over-many-files-with-perl\/","title":{"rendered":"Shell: Find and Repleace String over many files with Perl"},"content":{"rendered":"<p>From: <a href=\"https:\/\/snippets.dzone.com\/posts\/show\/116\">https:\/\/snippets.dzone.com\/posts\/show\/116<\/a><\/p>\n<blockquote><p>An equivalent of the other find-replace, except it&#8217;s a one-liner that generates no temp files, and is more flexible:<\/p>\n<p><code>perl -pi -e 's\/find\/replace\/g' *.txt<\/code><\/p>\n<p>Or, to change matching files in a hierarchy:<\/p>\n<p><code>find . -name '*.txt' |xargs perl -pi -e 's\/find\/replace\/g'<\/code><\/p><\/blockquote>\n<blockquote><p>That didn&#8217;t work when the file names contained white space. This seems to work even with them (with GNU find and xargs):<\/p>\n<p><code>find . -name '*.txt' -print0 |xargs -0 perl -pi -e 's\/find\/replace\/g'<\/code><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>From: https:\/\/snippets.dzone.com\/posts\/show\/116 An equivalent of the other find-replace, except it&#8217;s a one-liner that generates no temp files, and is more flexible: perl -pi -e &#8216;s\/find\/replace\/g&#8217; *.txt Or, to change matching files in a hierarchy: find . -name &#8216;*.txt&#8217; |xargs perl -pi -e &#8216;s\/find\/replace\/g&#8217; That didn&#8217;t work when the file names contained white space. This seems [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8],"tags":[14,24,49,50],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-perl","category-shell","tag-bash","tag-find-and-repleace","tag-perl","tag-shell"],"_links":{"self":[{"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":0,"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.timk.de\/it-blog\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}