<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://hurlster.com/wiki/index.php?action=history&amp;feed=atom&amp;title=FindReplace</id>
	<title>FindReplace - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://hurlster.com/wiki/index.php?action=history&amp;feed=atom&amp;title=FindReplace"/>
	<link rel="alternate" type="text/html" href="https://hurlster.com/wiki/index.php?title=FindReplace&amp;action=history"/>
	<updated>2026-08-26T01:29:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.4</generator>
	<entry>
		<id>https://hurlster.com/wiki/index.php?title=FindReplace&amp;diff=2548&amp;oldid=prev</id>
		<title>Gqwill69: /* Find Execute */</title>
		<link rel="alternate" type="text/html" href="https://hurlster.com/wiki/index.php?title=FindReplace&amp;diff=2548&amp;oldid=prev"/>
		<updated>2013-05-01T18:50:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Find Execute&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This script searches a directory recursively and finds/replaces text.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/perl &lt;br /&gt;
&lt;br /&gt;
use strict; &lt;br /&gt;
use warnings; &lt;br /&gt;
use File::Find; &lt;br /&gt;
&lt;br /&gt;
my $startdir = &amp;#039;/var/www/directory/&amp;#039;; &lt;br /&gt;
my $find = &amp;#039;foo&amp;#039;; &lt;br /&gt;
my $replace = &amp;#039;bar&amp;#039;; &lt;br /&gt;
my $doctype = &amp;#039;cgi&amp;#039;;  &lt;br /&gt;
&lt;br /&gt;
print qq~Finding &amp;quot;$find&amp;quot; and replacing it with &amp;quot;$replace&amp;quot;\n~; &lt;br /&gt;
&lt;br /&gt;
find( &lt;br /&gt;
   sub{ &lt;br /&gt;
      return unless (/\.$doctype$/i); &lt;br /&gt;
      local @ARGV = $_; &lt;br /&gt;
      local $^I = &amp;#039;.bac&amp;#039;; &lt;br /&gt;
      while( &amp;lt;&amp;gt; ){ &lt;br /&gt;
         if( s/$find/$replace/ig ) { &lt;br /&gt;
            print; &lt;br /&gt;
         } &lt;br /&gt;
         else { &lt;br /&gt;
            print; &lt;br /&gt;
         } &lt;br /&gt;
      } &lt;br /&gt;
}, $startdir);&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Finished&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Find by Date ===&lt;br /&gt;
 find . -maxdepth 1 -type f -newermt 2007-10-01 ! -newermt 2007-10-02 -ls&lt;br /&gt;
*To Delete&lt;br /&gt;
 find . -maxdepth 1 -type f -newermt 2007-10-01 ! -newermt 2007-10-02 -delete&lt;br /&gt;
&lt;br /&gt;
=== SED remove line ===&lt;br /&gt;
* Delete &amp;quot;SetEnv&amp;quot; and everything after plus 5 lines below&lt;br /&gt;
 sed &amp;#039;/^SetEnv.*/,+5d&amp;#039; file.txt&lt;br /&gt;
&lt;br /&gt;
=== Find Execute ===&lt;br /&gt;
 find . -type f -name \*.avi -exec mv {} ./ \;&lt;br /&gt;
&lt;br /&gt;
=== Rename ===&lt;br /&gt;
Using &amp;quot;rename&amp;quot; utility to Uppercase first letter in each word.&lt;br /&gt;
 rename -v &amp;#039;s/\b(\w)/\u$1/g&amp;#039; myfile\ name\ here.txt&lt;br /&gt;
 myfile name here.txt renamed as Myfile\ Name Here.txt&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux]]&lt;/div&gt;</summary>
		<author><name>Gqwill69</name></author>
	</entry>
</feed>