find and searching for specific expression in files

Polytropon freebsd at edvax.de
Sat May 30 16:32:47 UTC 2009


On Sat, 30 May 2009 11:25:12 +0200, "Zbigniew Szalbot" <z.szalbot at lcwords.com> wrote:
> Hello,
> 
> Can you please give me a hint how to use find to search for a specific
> text within files?

One valid solution is to combine find (to find the files) and
grep (to search in them). For the combination, you can use
the famous back-tics.

	% grep "expression" `find /path/to/files/ -mtime -2 -print`

Of course, there are surely easier, faster and better means,
but from this one, I know it just works. :-) Furthermore, I
think -print is optional here.

If you want to use the Midnight Commander, use Meta-? for a
combined dialog:

	+----------------- Find File ------------------+
	|                                              |
	| Start at: _______________________________[^] |
	|                                              |
	| Filename: _______________________________[^] |
	|                                              |
	| Content:  _______________________________[^] |
	|                                              |
	| [ ] case Sensitive                           |
	|                                              |
	| [< OK >]  [ Tree ]                [ Cancel ] |
	+----------------------------------------------+

That's what I mostly use.




-- 
Polytropon
>From Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list