On Sat, May 30, 2009 at 3:12 PM, Mel Flynn < [email protected]<mel.flynn%[email protected]> > wrote:
> On Saturday 30 May 2009 13:56:22 Valentin Bud wrote: > > 2009/5/30 Zbigniew Szalbot <[email protected]> > > > > > >> Can you please give me a hint how to use find to search for a > specific > > > >> text within files? > > > > > > > > Generally, you don't - find(1) does not examine the contents of files > > > > by itself, just their directory information. You normally use > grep(1) > > > > to search within a file. > > > > > > Ahhh - I use grep on daily basis. Now why didn't I think of it? I got > so > > > fixed on the idea of using find that I completely forgot about grep.... > > > > > > Sorry for the noise and thank you very much for your help! > > > > > > -- > > > Zbigniew Szalbot > > > > > > _______________________________________________ > > > [email protected] mailing list > > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > > > To unsubscribe, send any mail to " > > > [email protected]" > > > > Hello Mr. Zbigniew Szalbot, > > > > You can use egrep -r * (grep -e) to search for specific text pattern > while > > you are in a directory with many sub directories. The output is nice > > because it tells you the file in which the text pattern was found :). > > Discouraged because: > - it's possible to hit maxarglen if the root directory has many > subdirectories. Never occured so i didn't have a clue about it :|. > > - Will not search hidden directories in the root directory because of the > shell glob > - cannot be combined with other search criteria such as the file's > timestamp. > > find . -type f -mtime 2 -exec grep '^Subject: \[SPAM\]' {} + > > will find all messages in a maildir modified within the last 2 minutes > where > the subject has been flagged as spam. I use + rather then ; so that one > invocation for grep is done whenever maxarglen is hit (like if you used > xargs(1)), rather then one grep per file. > -- > Mel This list is amazing because everyday you learn something new. Thanks. a great day, v -- network warrior since 2005 _______________________________________________ [email protected] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[email protected]"
