<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Perl Oneliner: Recursive Search and Replace</title>
	<atom:link href="http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/feed/" rel="self" type="application/rss+xml" />
	<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/</link>
	<description>cat /dev/random</description>
	<lastBuildDate>Sat, 04 Jul 2009 08:07:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9-rare</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jameson Quave</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-890911</link>
		<dc:creator>Jameson Quave</dc:creator>
		<pubDate>Tue, 16 Jun 2009 15:46:23 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-890911</guid>
		<description>Thanks a bunch! This saves me a lot of time on a daily basis as I&#039;ve started using this in a script. Just thought I&#039;d come let you know it helped. Although you need to add &quot;quotes&quot; around your find target for this to work properly.</description>
		<content:encoded><![CDATA[<p>Thanks a bunch! This saves me a lot of time on a daily basis as I&#8217;ve started using this in a script. Just thought I&#8217;d come let you know it helped. Although you need to add &#8220;quotes&#8221; around your find target for this to work properly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Golvach</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-489726</link>
		<dc:creator>Mike Golvach</dc:creator>
		<pubDate>Tue, 24 Jun 2008 09:50:12 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-489726</guid>
		<description>I should note, that, with the script, you&#039;ll at least get a line number that probably won&#039;t be 1 ;)</description>
		<content:encoded><![CDATA[<p>I should note, that, with the script, you&#8217;ll at least get a line number that probably won&#8217;t be 1 ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Golvach</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-489722</link>
		<dc:creator>Mike Golvach</dc:creator>
		<pubDate>Tue, 24 Jun 2008 09:48:49 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-489722</guid>
		<description>Hey There,

That error almost always has to do with unmatched quotation marks.  Probably, the easiest way to figure out what&#039;s wrong with it would be to turn your one-liner into a simple script.   You&#039;ll get waaaaaay too much information, but the answer will probably be in there.

If not, check test1.txt for any unmatched double quotes, single quotes, backticks, etc and that may lead you to the answer, as well.

Best wishes,

Mike</description>
		<content:encoded><![CDATA[<p>Hey There,</p>
<p>That error almost always has to do with unmatched quotation marks.  Probably, the easiest way to figure out what&#8217;s wrong with it would be to turn your one-liner into a simple script.   You&#8217;ll get waaaaaay too much information, but the answer will probably be in there.</p>
<p>If not, check test1.txt for any unmatched double quotes, single quotes, backticks, etc and that may lead you to the answer, as well.</p>
<p>Best wishes,</p>
<p>Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-484369</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 20 Jun 2008 22:58:17 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-484369</guid>
		<description>hello all 

I execute this:

# perl -p -w -e &#039;s/(?:\n)(.*)//g&#039; test1.txt

And get this:

Bareword found where operator expected at -e line 1, near &quot;s/(?:\n)(.*)&lt;/collectioninfo&quot;
Unquoted string &quot;collectioninfo&quot; may clash with future reserved word at -e line 1.
syntax error at -e line 1, near &quot;s/(?:\n)(.*)&lt;/collectioninfo&quot;
Execution of -e aborted due to compilation errors.


Any help ? 

Thx !!</description>
		<content:encoded><![CDATA[<p>hello all </p>
<p>I execute this:</p>
<p># perl -p -w -e &#8217;s/(?:\n)(.*)//g&#8217; test1.txt</p>
<p>And get this:</p>
<p>Bareword found where operator expected at -e line 1, near &#8220;s/(?:\n)(.*)&lt;/collectioninfo&#8221;<br />
Unquoted string &#8220;collectioninfo&#8221; may clash with future reserved word at -e line 1.<br />
syntax error at -e line 1, near &#8220;s/(?:\n)(.*)&lt;/collectioninfo&#8221;<br />
Execution of -e aborted due to compilation errors.</p>
<p>Any help ? </p>
<p>Thx !!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Golvach</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-430735</link>
		<dc:creator>Mike Golvach</dc:creator>
		<pubDate>Tue, 13 May 2008 03:36:18 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-430735</guid>
		<description>Hey There,

For &quot;not replacing&quot; files that already exist, I use this with that perl one-liner when I&#039;m piping filenames to it - it&#039;s not built into the options, but is pretty simple to type once :)

perl -p -i -e &#039;s/ThisThing/ThatThing/; rename $_, unless -e $_;&#039;

It doesn&#039;t work &quot;out of context&quot; because $_ requires a value, but you can use the rename half of my version of the one-liner to insert in the previous code to prevent against overwriting :)

Great post :)

, Mike</description>
		<content:encoded><![CDATA[<p>Hey There,</p>
<p>For &#8220;not replacing&#8221; files that already exist, I use this with that perl one-liner when I&#8217;m piping filenames to it &#8211; it&#8217;s not built into the options, but is pretty simple to type once :)</p>
<p>perl -p -i -e &#8217;s/ThisThing/ThatThing/; rename $_, unless -e $_;&#8217;</p>
<p>It doesn&#8217;t work &#8220;out of context&#8221; because $_ requires a value, but you can use the rename half of my version of the one-liner to insert in the previous code to prevent against overwriting :)</p>
<p>Great post :)</p>
<p>, Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-418496</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Thu, 01 May 2008 17:28:19 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-418496</guid>
		<description>Carlos, perl -pi -e replaces the CONTENTS of the file.  You are trying to RENAME the file.  Two very different things.  See if you have the rename command; it is a perl script and will let you rename a file using regex substitution.</description>
		<content:encoded><![CDATA[<p>Carlos, perl -pi -e replaces the CONTENTS of the file.  You are trying to RENAME the file.  Two very different things.  See if you have the rename command; it is a perl script and will let you rename a file using regex substitution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carlos</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-363863</link>
		<dc:creator>Carlos</dc:creator>
		<pubDate>Fri, 22 Feb 2008 17:39:42 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-363863</guid>
		<description>I tried all these examples to no avail using Solaris9, just trying to find all files in filesystem with *.zip and change it to *.ZIP.

# perl -v

This is perl, v5.6.1 built for sun4-solaris-64int
(with 48 registered patches, see perl -V for more detail)

# find /usr/local/tmp/aaa -name &quot;*.zip&quot; -exec perl -p -i -e &#039;s/zip/ZIP/g&#039; {} \;

# ls -l /usr/local/tmp/aaa
total 6
-rw-r--r--   1 carlos   staff         49 Feb 22 09:35 9_Recommended.zip
-rw-r--r--   1 carlos   staff         49 Feb 22 09:35 DLG_V11_2.zip
-rw-r--r--   1 carlos   staff         49 Feb 22 09:35 tzupdater-1_0_1.zip
# 

Single quotes doesn&#039;t work too

# find /usr/local/tmp/aaa -name &#039;*.zip&#039; -exec perl -p -i -e &#039;s/zip/ZIP/g&#039; {} \;
# ls -l /usr/local/tmp/aaa
total 6
-rw-r--r--   1 carlos   staff         49 Feb 22 09:37 9_Recommended.zip
-rw-r--r--   1 carlos   staff         49 Feb 22 09:37 DLG_V11_2.zip
-rw-r--r--   1 carlos   staff         49 Feb 22 09:37 tzupdater-1_0_1.zip</description>
		<content:encoded><![CDATA[<p>I tried all these examples to no avail using Solaris9, just trying to find all files in filesystem with *.zip and change it to *.ZIP.</p>
<p># perl -v</p>
<p>This is perl, v5.6.1 built for sun4-solaris-64int<br />
(with 48 registered patches, see perl -V for more detail)</p>
<p># find /usr/local/tmp/aaa -name &#8220;*.zip&#8221; -exec perl -p -i -e &#8217;s/zip/ZIP/g&#8217; {} \;</p>
<p># ls -l /usr/local/tmp/aaa<br />
total 6<br />
-rw-r&#8211;r&#8211;   1 carlos   staff         49 Feb 22 09:35 9_Recommended.zip<br />
-rw-r&#8211;r&#8211;   1 carlos   staff         49 Feb 22 09:35 DLG_V11_2.zip<br />
-rw-r&#8211;r&#8211;   1 carlos   staff         49 Feb 22 09:35 tzupdater-1_0_1.zip<br />
# </p>
<p>Single quotes doesn&#8217;t work too</p>
<p># find /usr/local/tmp/aaa -name &#8216;*.zip&#8217; -exec perl -p -i -e &#8217;s/zip/ZIP/g&#8217; {} \;<br />
# ls -l /usr/local/tmp/aaa<br />
total 6<br />
-rw-r&#8211;r&#8211;   1 carlos   staff         49 Feb 22 09:37 9_Recommended.zip<br />
-rw-r&#8211;r&#8211;   1 carlos   staff         49 Feb 22 09:37 DLG_V11_2.zip<br />
-rw-r&#8211;r&#8211;   1 carlos   staff         49 Feb 22 09:37 tzupdater-1_0_1.zip</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flavien</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-217462</link>
		<dc:creator>Flavien</dc:creator>
		<pubDate>Wed, 01 Aug 2007 10:35:11 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-217462</guid>
		<description>Using grep to select the files is a performance killer : It means that the files matching the regexp will be scanned twice : Once by grep and once by perl. If the file is big, it&#039;s a problem.

Not selecting the files that will be changed is a problem: Files that do not match will change (ie time, inode). Not good for keeping timestamps of unchanged files (think for example source files: make will rebuild the objects!)

/me is wondering if perl has an option &quot;do not replace the file by a new one if it did not change, just keep it&quot;.</description>
		<content:encoded><![CDATA[<p>Using grep to select the files is a performance killer : It means that the files matching the regexp will be scanned twice : Once by grep and once by perl. If the file is big, it&#8217;s a problem.</p>
<p>Not selecting the files that will be changed is a problem: Files that do not match will change (ie time, inode). Not good for keeping timestamps of unchanged files (think for example source files: make will rebuild the objects!)</p>
<p>/me is wondering if perl has an option &#8220;do not replace the file by a new one if it did not change, just keep it&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam ruck</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-193811</link>
		<dc:creator>Adam ruck</dc:creator>
		<pubDate>Mon, 18 Jun 2007 18:37:36 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-193811</guid>
		<description>Hey guys, be careful with your symlinks! I used Nics method from post number 2, and it converted my symlink files to real files. That ended up breaking some stuff for me.</description>
		<content:encoded><![CDATA[<p>Hey guys, be careful with your symlinks! I used Nics method from post number 2, and it converted my symlink files to real files. That ended up breaking some stuff for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PrestonLee.com</title>
		<link>http://joseph.randomnetworks.com/archives/2005/08/18/perl-oneliner-recursive-search-and-replace/comment-page-1/#comment-145477</link>
		<dc:creator>PrestonLee.com</dc:creator>
		<pubDate>Wed, 21 Mar 2007 07:31:06 +0000</pubDate>
		<guid isPermaLink="false">http://joseph.randomnetworks.com/?p=458#comment-145477</guid>
		<description>&lt;strong&gt;Shell Magic: Globally Find/Replace Text Using RegExps Within Many Files...&lt;/strong&gt;

Here’s one of my favorite Perl-based one-liners which I whip out when I need to find a bunch of files and replace text based on regular expressions at the command line.
find . -iname &#8216;*.js&#8217; -exec perl -pi.bak -e &#8217;s/2006/2007/g&amp;#8217...</description>
		<content:encoded><![CDATA[<p><strong>Shell Magic: Globally Find/Replace Text Using RegExps Within Many Files&#8230;</strong></p>
<p>Here’s one of my favorite Perl-based one-liners which I whip out when I need to find a bunch of files and replace text based on regular expressions at the command line.<br />
find . -iname &#8216;*.js&#8217; -exec perl -pi.bak -e &#8217;s/2006/2007/g&amp;#8217&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
