Re: Finding files containing 'string'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



akonstam@xxxxxxxxxxx wrote:
On Wed, Feb 01, 2006 at 04:22:07PM -0500, CodeHeads wrote:
> On Wed, 2006-02-01 at 20:49 +0000, Anne Wilson wrote:
> > On Wednesday 01 Feb 2006 20:41, CodeHeads wrote:
> > >
> > > How about this:
> > >
> > > $du -a | grep
> > >
> > > This works well for me.
> >
> > That returns files with the string in the name, I believe. I need files
> > with the string in the body.
> >
> > Anne
>
> oooppss sorry Anne :) I was confused. LOL
> --
I had two suggestions:
1. gnome-search-tool
2. find ./ -name "*" -exec grep "string" {} /dev/null \;

Someone suggested even a better command solution than 2. ! above but I
can't remember what it is.
--

Actually, find is recursive by nature so there is no need to use filename expansion metacharacters (such as * ) if one is searching in all files. So. . . if you are searching for text, rather than digits . . .
 
#  cd /dir  (could be / if you need to search all mounted files systems)
#  find . -type f  -exec grep -i "string" {} /dev/null \;           OR
 
#  find . -type f  -exec egrep -i "string|string|string" {} \; 
   If you are searching for multiple patterns.  OR
 
# find . -name '*.txt' -type f -exec grep -i "string" {} \;
If you are searching only in files with a .txt. extention.
--
Nix

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux