{"id":82,"date":"2008-01-17T10:43:59","date_gmt":"2008-01-17T08:43:59","guid":{"rendered":"http:\/\/www.shukko.com\/x3\/2008\/01\/17\/how-to-do-a-search-and-replace-over-multiple-files\/"},"modified":"2017-11-02T01:20:34","modified_gmt":"2017-11-01T23:20:34","slug":"how-to-do-a-search-and-replace-over-multiple-files","status":"publish","type":"post","link":"https:\/\/www.shukko.com\/x3\/2008\/01\/17\/how-to-do-a-search-and-replace-over-multiple-files\/","title":{"rendered":"How to do a search and replace over multiple files"},"content":{"rendered":"<p>linux konsolda Birden cok dosya icinde bul ve degistir islemleri yapmak.<\/p>\n<p>Bu kod yeni sunuculardan bir tanesine aktarilan domainlerin dnslerinde yapilmasi gereken degisikler icin gerekti.<\/p>\n<p>Basariyla uygulandi.<\/p>\n<p>ingilizce metin su sekilde:<\/p>\n<p><code><br \/>\nYou could also use find and sed, but I find that this little line of perl works nicely.<br \/>\nperl -pi -w -e 's\/search\/replace\/g;' *.php<\/code><code>-e means execute the following line of code.<br \/>\n-i means edit in-place<br \/>\n-w write warnings<br \/>\n-p loop<\/code><\/p>\n<p>Example I had the following style sheet in a section:<br \/>\nand I wanted the following instead:<br \/>\nAs each expression is a regular expression you&#8217;ve got to escape the special characters such as forward slash and .<br \/>\n\\.\\.\\\/includes\\\/style\\.css<\/p>\n<p>So the final line of code ends up as<br \/>\nperl -pi -w -e &#8216;s\/\\.\\.\\\/includes\\\/style\\.css\/admin\\.css\/g;&#8217; *.php<\/p>\n<p>Benim uguladigim sekilde ise :<\/p>\n<p>\/var\/named\/*.db dosyalarinda<br \/>\nns1.eskidomain.net.<br \/>\nadresinin<\/p>\n<p>ns1.yenidomain.org.<br \/>\nile degistirilmesi gerek<\/p>\n<p><code><br \/>\n[root@pbserver named]# perl -pi -w -e 's\/ns1\\.eskidomain\\.net\\.\/ns1\\.yenidomain\\.org\\.\/g;' *.db<br \/>\n[root@pbserver named]# perl -pi -w -e 's\/ns2\\.eskidomain\\.net\\.\/ns2\\.yenidomain\\.org\\.\/g;' *.db<br \/>\n<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>000000000000000000000000000000000<\/p>\n<p>EK 1 KASIM 2017<\/p>\n<p>=================================<\/p>\n<p>find and replace etmenin yolu daha degisik sekilde<\/p>\n<pre class=\"lang:default decode:true \">for E in `cat aaa.txt`; do perl -pi -w -e 's\/content type\/content_type\/g;' $E; done\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux konsolda Birden cok dosya icinde bul ve degistir islemleri yapmak. Bu kod yeni sunuculardan bir tanesine aktarilan domainlerin dnslerinde yapilmasi gereken degisikler icin gerekti. Basariyla uygulandi. ingilizce metin su sekilde: You could also use find and sed, but I find that this little line of perl works nicely. perl -pi -w -e &#8216;s\/search\/replace\/g;&#8217; *.php-e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-82","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":2,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":1332,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/82\/revisions\/1332"}],"wp:attachment":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/categories?post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/tags?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}