<?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: Finding a File containing a particular text string in Linux server</title> <atom:link href="http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: shawn</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-65670</link> <dc:creator>shawn</dc:creator> <pubDate>Thu, 15 Dec 2011 18:17:44 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-65670</guid> <description>re: da_bull97, i&#039;ve recently been hacked, and I used this command to find a specific word on my server throughout 100+ sites &gt; and save the result to a text file.
grep -r &quot;base64_decode&quot; /home/ &gt; /home/domain/public_html/results.txt</description> <content:encoded><![CDATA[<p>re: da_bull97, i&#8217;ve recently been hacked, and I used this command to find a specific word on my server throughout 100+ sites &gt; and save the result to a text file.</p><p>grep -r &#8220;base64_decode&#8221; /home/ &gt; /home/domain/public_html/results.txt</p> ]]></content:encoded> </item> <item><title>By: da_bull97</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-64397</link> <dc:creator>da_bull97</dc:creator> <pubDate>Sun, 13 Nov 2011 06:12:14 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-64397</guid> <description>I have an interesting question that ive been searching for a long time. would there be any way, to use a grep command to search for files based on words found in a text file?
for example, lets say i have a text file with the names of a bunch of songs i want to delete from directory /home/music. I want to be able to create a script that would search for the songs in /home/music from the text file.
any ideas?</description> <content:encoded><![CDATA[<p>I have an interesting question that ive been searching for a long time. would there be any way, to use a grep command to search for files based on words found in a text file?</p><p>for example, lets say i have a text file with the names of a bunch of songs i want to delete from directory /home/music. I want to be able to create a script that would search for the songs in /home/music from the text file.</p><p>any ideas?</p> ]]></content:encoded> </item> <item><title>By: Search_it</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-64338</link> <dc:creator>Search_it</dc:creator> <pubDate>Fri, 11 Nov 2011 11:21:02 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-64338</guid> <description>Hello,
I want to search string ,but i dont know that string present in which file name or where it is present.Is there any unix command for searching such kind of string.?</description> <content:encoded><![CDATA[<p>Hello,<br
/> I want to search string ,but i dont know that string present in which file name or where it is present.Is there any unix command for searching such kind of string.?</p> ]]></content:encoded> </item> <item><title>By: alan</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-63963</link> <dc:creator>alan</dc:creator> <pubDate>Sat, 29 Oct 2011 19:04:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-63963</guid> <description>I am totally green in this... can anyone tell me how to find files which contain the same name of file and  the same string in file? [name of file = file contain the same string/ text  as name of the file]</description> <content:encoded><![CDATA[<p>I am totally green in this&#8230; can anyone tell me how to find files which contain the same name of file and  the same string in file? [name of file = file contain the same string/ text  as name of the file]</p> ]]></content:encoded> </item> <item><title>By: clark</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-62981</link> <dc:creator>clark</dc:creator> <pubDate>Fri, 30 Sep 2011 03:49:35 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-62981</guid> <description>for my version of linux, I had to move the -print in front. plus i added some params for grep
find . -type f -print -exec grep -inH &quot;redeem reward&quot; {} \;</description> <content:encoded><![CDATA[<p>for my version of linux, I had to move the -print in front. plus i added some params for grep</p><p>find . -type f -print -exec grep -inH &#8220;redeem reward&#8221; {} \;</p> ]]></content:encoded> </item> <item><title>By: Karthick K</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-62074</link> <dc:creator>Karthick K</dc:creator> <pubDate>Thu, 01 Sep 2011 14:48:01 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-62074</guid> <description>Hi
I have to move n number of files from one path to another path. No matter what the file name is. Can I get the command for doing this? Unix as well as in Windows.
Any help is appreciated.
Thanks,
Karthick K</description> <content:encoded><![CDATA[<p>Hi</p><p>I have to move n number of files from one path to another path. No matter what the file name is. Can I get the command for doing this? Unix as well as in Windows.</p><p>Any help is appreciated.</p><p>Thanks,<br
/> Karthick K</p> ]]></content:encoded> </item> <item><title>By: Vivek M Garg</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-61225</link> <dc:creator>Vivek M Garg</dc:creator> <pubDate>Tue, 02 Aug 2011 08:00:18 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-61225</guid> <description>Can also try grep -r &quot;\-g&quot; /home/user/src
It works in Linux.
-- &#039;-g&#039; also works as sugested by Vivek Gite</description> <content:encoded><![CDATA[<p>Can also try grep -r &#8220;\-g&#8221; /home/user/src</p><p>It works in Linux.</p><p>&#8211; &#8216;-g&#8217; also works as sugested by Vivek Gite</p> ]]></content:encoded> </item> <item><title>By: Vivek Gite</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-61221</link> <dc:creator>Vivek Gite</dc:creator> <pubDate>Tue, 02 Aug 2011 07:14:22 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-61221</guid> <description>&lt;pre&gt;
grep -r -- &#039;-g&#039; /home/user/src
&lt;/pre&gt;</description> <content:encoded><![CDATA[<pre>
grep -r -- '-g' /home/user/src
</pre>]]></content:encoded> </item> <item><title>By: chris pepper</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-61205</link> <dc:creator>chris pepper</dc:creator> <pubDate>Mon, 01 Aug 2011 13:14:49 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-61205</guid> <description>how do i search for a string containing &quot;-g&quot; ?? whenever i do
grep -r &quot;-g&quot; /home/user/src
it says &quot;invalid option -g&quot; how do i stop it picking it up as an option? I also tried
grep -r &quot;cc&quot; /home/user/src/*.mak and it says:
&quot; /home/user/src/*.mak: no such file or directory&quot; is this because of the -r option?
I appreciate any help!
-Thanks, Chris</description> <content:encoded><![CDATA[<p>how do i search for a string containing &#8220;-g&#8221; ?? whenever i do<br
/> grep -r &#8220;-g&#8221; /home/user/src</p><p>it says &#8220;invalid option -g&#8221; how do i stop it picking it up as an option? I also tried</p><p>grep -r &#8220;cc&#8221; /home/user/src/*.mak and it says:<br
/> &#8221; /home/user/src/*.mak: no such file or directory&#8221; is this because of the -r option?</p><p>I appreciate any help!</p><p>-Thanks, Chris</p> ]]></content:encoded> </item> <item><title>By: Carsten</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-60035</link> <dc:creator>Carsten</dc:creator> <pubDate>Thu, 16 Jun 2011 08:35:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-60035</guid> <description>Hi T.,
use: grep &quot;\b2012.\{12\}\b&quot;
That means: any word (marked by \b) starting with 2012 followed by any character (&quot;.&quot;) repeated 12 times.
Carsten</description> <content:encoded><![CDATA[<p>Hi T.,</p><p>use: grep &#8220;\b2012.\{12\}\b&#8221;</p><p>That means: any word (marked by \b) starting with 2012 followed by any character (&#8220;.&#8221;) repeated 12 times.</p><p>Carsten</p> ]]></content:encoded> </item> <item><title>By: Tlucz-huba</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-57601</link> <dc:creator>Tlucz-huba</dc:creator> <pubDate>Sat, 23 Apr 2011 08:44:20 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-57601</guid> <description>Hi guys,
can you please help me out with a grep command to find a 16 chars long string that starts with number &#039;2012&#039; and then followed by any characters?
Thank you,
T.</description> <content:encoded><![CDATA[<p>Hi guys,</p><p>can you please help me out with a grep command to find a 16 chars long string that starts with number &#8217;2012&#8242; and then followed by any characters?</p><p>Thank you,</p><p>T.</p> ]]></content:encoded> </item> <item><title>By: lindsey</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-56733</link> <dc:creator>lindsey</dc:creator> <pubDate>Thu, 31 Mar 2011 01:47:07 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-56733</guid> <description>this works but again, i have to know hte positions to make it work correctly:
# ps -aefk &#124; awk &#039;/-Xm/ {print $14,$15,$NF}&#039;
-Xms256m -Xmx1024m server1
-Xms50m -Xmx256m nodeagent</description> <content:encoded><![CDATA[<p>this works but again, i have to know hte positions to make it work correctly:<br
/> # ps -aefk | awk &#8216;/-Xm/ {print $14,$15,$NF}&#8217;<br
/> -Xms256m -Xmx1024m server1<br
/> -Xms50m -Xmx256m nodeagent</p> ]]></content:encoded> </item> <item><title>By: lindsey</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-56732</link> <dc:creator>lindsey</dc:creator> <pubDate>Thu, 31 Mar 2011 01:45:39 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-56732</guid> <description>hi all, kind of a continuation of the original Q but need text from the &quot;process table&quot; in AIX not a file:
java process &amp; need to parse out anything &quot;-Xm&quot;, appreciate any help, been banging my head trying: awk, cut, sed  (noob here), perl (noob here) and it kinda works but i have to figure out the &quot;positions of the fields&quot; i need to make them work ($15,$16,$NF), i need a way to parse an unknown &#039;position in a string&#039;.  hope this makes sense, thx much.</description> <content:encoded><![CDATA[<p>hi all, kind of a continuation of the original Q but need text from the &#8220;process table&#8221; in AIX not a file:<br
/> java process &amp; need to parse out anything &#8220;-Xm&#8221;, appreciate any help, been banging my head trying: awk, cut, sed  (noob here), perl (noob here) and it kinda works but i have to figure out the &#8220;positions of the fields&#8221; i need to make them work ($15,$16,$NF), i need a way to parse an unknown &#8216;position in a string&#8217;.  hope this makes sense, thx much.</p> ]]></content:encoded> </item> <item><title>By: Me</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-53565</link> <dc:creator>Me</dc:creator> <pubDate>Sat, 25 Dec 2010 08:56:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-53565</guid> <description>grep -Hr &quot;TEXT_TO_FIND&quot;
i.e. grep -Hr &quot;Me&quot; /home/earth</description> <content:encoded><![CDATA[<p>grep -Hr &#8220;TEXT_TO_FIND&#8221;</p><p>i.e. grep -Hr &#8220;Me&#8221; /home/earth</p> ]]></content:encoded> </item> <item><title>By: Russ</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52527</link> <dc:creator>Russ</dc:creator> <pubDate>Wed, 15 Dec 2010 21:12:09 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52527</guid> <description>great people, helpful but what Vivek write is for me to difficult. May be it&#039;s time to start learning sed or awk :-)
Thx2all</description> <content:encoded><![CDATA[<p>great people, helpful but what Vivek write is for me to difficult. May be it&#8217;s time to start learning sed or awk :-)<br
/> Thx2all</p> ]]></content:encoded> </item> <item><title>By: Vivek</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52478</link> <dc:creator>Vivek</dc:creator> <pubDate>Wed, 15 Dec 2010 13:24:42 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52478</guid> <description>Welcome !
Yes it&#039;s short &amp; better for sure. Did not try with -exec earlier.
Perfect if there are no blank spaces / special characters in file names.
Take care.
Vivek M Garg</description> <content:encoded><![CDATA[<p>Welcome !</p><p>Yes it&#8217;s short &amp; better for sure. Did not try with -exec earlier.<br
/> Perfect if there are no blank spaces / special characters in file names.</p><p>Take care.<br
/> Vivek M Garg</p> ]]></content:encoded> </item> <item><title>By: Albert</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52347</link> <dc:creator>Albert</dc:creator> <pubDate>Tue, 14 Dec 2010 17:10:29 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52347</guid> <description>thanks!!!
i found a nother way to do that:
find /home/ -exec grep -l &quot;mp3&quot; {} \; &#124; xargs rm
i hope this help someone</description> <content:encoded><![CDATA[<p>thanks!!!</p><p>i found a nother way to do that:</p><p>find /home/ -exec grep -l &#8220;mp3&#8243; {} \; | xargs rm</p><p>i hope this help someone</p> ]]></content:encoded> </item> <item><title>By: Vivek</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52322</link> <dc:creator>Vivek</dc:creator> <pubDate>Tue, 14 Dec 2010 13:56:17 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52322</guid> <description>Let&#039;s assume:-
files to search = *.txt
Directory to be searched=/tmp
search string=hello
Let&#039;s also assume that file names *.txt also contain blank spaces as
&quot;/tmp/1st  file.txt&quot;
First verify that you get the names of the correct files to be deleted as follows:
# find /tmp -type f -name &#039;*.txt*&#039; &#124; sed -e &#039;s/.*/\&quot;&amp;\&quot;/&#039; &#124;xargs -n 1 grep -l hello&#124;sed -e &#039;s/.*/\&quot;&amp;\&quot;/&#039;
( Here sed is used to deal with blank spaces within file names )
After confirming that the results are ok, files can be deleted by piping &amp; xargs as follows:
# find /tmp -type f -name &#039;*.txt*&#039; &#124; sed -e &#039;s/.*/\&quot;&amp;\&quot;/&#039; &#124;xargs -n 1 grep -l hello&#124;sed -e &#039;s/.*/\&quot;&amp;\&quot;/&#039;&#124;xargs -n 1 rm -f
Note: If the search string has blank spaces, place the entire &quot;search string&quot; within &quot;Double quotes&quot; .</description> <content:encoded><![CDATA[<p>Let&#8217;s assume:-<br
/> files to search = *.txt<br
/> Directory to be searched=/tmp<br
/> search string=hello<br
/> Let&#8217;s also assume that file names *.txt also contain blank spaces as<br
/> &#8220;/tmp/1st  file.txt&#8221;<br
/> First verify that you get the names of the correct files to be deleted as follows:</p><p># find /tmp -type f -name &#8216;*.txt*&#8217; | sed -e &#8216;s/.*/\&#8221;&amp;\&#8221;/&#8217; |xargs -n 1 grep -l hello|sed -e &#8216;s/.*/\&#8221;&amp;\&#8221;/&#8217;</p><p>( Here sed is used to deal with blank spaces within file names )</p><p>After confirming that the results are ok, files can be deleted by piping &amp; xargs as follows:</p><p># find /tmp -type f -name &#8216;*.txt*&#8217; | sed -e &#8216;s/.*/\&#8221;&amp;\&#8221;/&#8217; |xargs -n 1 grep -l hello|sed -e &#8216;s/.*/\&#8221;&amp;\&#8221;/&#8217;|xargs -n 1 rm -f</p><p>Note: If the search string has blank spaces, place the entire &#8220;search string&#8221; within &#8220;Double quotes&#8221; .</p> ]]></content:encoded> </item> <item><title>By: Albert</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52227</link> <dc:creator>Albert</dc:creator> <pubDate>Mon, 13 Dec 2010 20:58:10 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-52227</guid> <description>how can i search for a specific file content and delete them like a:
all file who have the word &quot;hello&quot; for example</description> <content:encoded><![CDATA[<p>how can i search for a specific file content and delete them like a:</p><p>all file who have the word &#8220;hello&#8221; for example</p> ]]></content:encoded> </item> <item><title>By: Vatar</title><link>http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-47320</link> <dc:creator>Vatar</dc:creator> <pubDate>Thu, 13 May 2010 16:31:06 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/#comment-47320</guid> <description>find . -type f -exec grep -i “redeem reward” {} \; -print 2&gt;/dev/null
to get rid of
grep: can&#039;t open ./var/adm/log/secret.log</description> <content:encoded><![CDATA[<p>find . -type f -exec grep -i “redeem reward” {} \; -print 2&gt;/dev/null<br
/> to get rid of<br
/> grep: can&#8217;t open ./var/adm/log/secret.log</p> ]]></content:encoded> </item> </channel> </rss>
