find function

Cameron Simpson cs at zip.com.au
Sun Apr 4 09:36:26 UTC 2004


On 16:13 23 Mar 2004, uuganbat <uuganbat at datacom.mn> wrote:
| I want to find a text from many files. How I want to find the files that
| are contain my searchin text.

Well if you have GNU grep (most Linux systems do) then:

	grep -r -l text-to-find directory-to-search

| Syntax of find is:	find path expression (example find / -name
| *.ini)

Using find, and restricting to *.ini files:

	find directory-to-search -type f -name '*.ini' -exec grep -l text-to-find {} /dev/null ';'

or:

	find directory-to-search -type f -name '*.ini' -print | xargs grep -l text-to-find /dev/null

See "man find" and "man grep" and "man xargs" to figure out how these
3 work.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

SCREECH! BUMP-BUMP! SCREECH! BUMP-BUMP! SCREECH! BUMP-BUMP! ZOOM!
   - the sound of a non-yuppie running over a show-dog
                                        -- George Scott





More information about the redhat-list mailing list