<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>usefulgeek &#187; find</title>
	<atom:link href="http://www.usefulgeek.com/blog/tag/find/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.usefulgeek.com/blog</link>
	<description>rants, reviews and kind hearted messages from some geeks</description>
	<lastBuildDate>Mon, 19 Jul 2010 16:48:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Find Text and Find/Replace Easier Than You Think in Linux</title>
		<link>http://www.usefulgeek.com/blog/2009/10/find-text-and-findreplace-easier-than-you-think-in-linux/</link>
		<comments>http://www.usefulgeek.com/blog/2009/10/find-text-and-findreplace-easier-than-you-think-in-linux/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 09:37:49 +0000</pubDate>
		<dc:creator>drale</dc:creator>
				<category><![CDATA[quickfire]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[rpl]]></category>
		<category><![CDATA[sed]]></category>

		<guid isPermaLink="false">http://www.usefulgeek.com/blog/?p=154</guid>
		<description><![CDATA[How to search all files for a text string:
grep -lr string ./ &#62; results.txt
-l will print only the path and file names of the matches.
Search all files of a certain name for a certain string:
grep -lr string ./ &#124; grep filename
Yes, do specify ./ if you are doing all directories within current.
(source and more info)
Find [...]


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><strong>How to search all files for a text string:</strong></p>
<pre>grep -lr string ./ &gt; results.txt</pre>
<p><code>-l</code> will print only the path and file names of the matches.</p>
<p>Search all files of a certain name for a certain string:</p>
<pre>grep -lr string ./ | grep filename</pre>
<p>Yes, do specify ./ if you are doing all directories within current.</p>
<p>(<a href="http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/">source and more info</a>)</p>
<p><strong>Find an replace a string in files:</strong><br />
Searching for a way to do this usually leads me to finding fancy scripts that don&#8217;t work right, are scary (create temp files, etc) or aren&#8217;t recursive. Just have backups at hand and test the following combination of <code>find</code> and <code>sed</code> before unleashing it, because it works great! You can test it by replacing <code>sed</code> with <code>grep</code></p>
<pre>find ./ -type f -exec sed -i ’s/string1/string2/’ {} \;</pre>
<p>Within specific file names/extentions&#8230;</p>
<pre>find ./ -iname \*.htm\* -exec sed -i 's/\-2005/\-2007/g' {} \;</pre>
<p>Don&#8217;t forget to use escape \ as seen above. And if your strings contain forward slash / just use a different delimiter such as pipe | or escape it.</p>
<p>You can also install rpl, as shown in the source pdf, for even cleaner line of code for executing your find and replace.</p>
<p>(<a href="http://www.sb.fsu.edu/~xray/Manuals/Search+Replace-v.2.pdf">source and more info</a>) A nice pdf to keep by your side.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.usefulgeek.com/blog/2009/10/find-text-and-findreplace-easier-than-you-think-in-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
