(Answer) (Category) Linux on PowerPC FAQ-O-Matic : (Category) Applications :
How do I find files on my system?
Let me count the ways! Read the man page on grep and find;
they're very powerful tools. Here are some examples:

find / -name \*fungi\* -print
    will find every file, directory, or other item on your system (note
    it starts at the root / directory) with "fungi" in its name.

find ~ -type f -exec grep fungi {} /dev/null \;
    will find every file in your home directory (~) containing the
    word fungi anywhere in it. The /dev/null is a trick to get grep
    to prefix its output with the pathname of the file it is searching.
    (This is inefficient because it spaws one grep per file. See the
    xargs solution below.)

locate foo
    Finds any files with "foo" in their names using a database that's
    automatically updated nightly. That is, it may miss files created
    today, or find files that were deleted today. You can change the
    frequency of the updates by editing /etc/crontab and modifying
    the line that runs updatedb. (Pointed out by Stelios K. Kyriacou.)
    Note: locate can be a security hole, since updatedb is run
    by root.  Any user can type "locate /root/" for example and see a
    list of files in the /root directory, or any other directory.
    slipcon@cs.jhu.edu

jonh@cs.dartmouth.edu

Ah but even cooler still are these lines from my .bashrc

rgrep () 
{ 
    find . ! -type d -print | xargs grep "$@"
}

which behaves just as grep in the current directory (allowing arguments etc)
but scans recursively. Note that using xargs avoids spawning huge of 'grep'
processes, so the search is more efficient than your suggestion above.

oh, I define 'crgrep' too which only scans through sourcefiles (by extension).

crgrep () 
{ 
    find . ! -type d -name '*.[cChdsS]' -print | xargs grep "$@"
}

-- from Nick STEPHEN, copied by jonh.
slipcon@cs.jhu.edu, jonh@cs.dartmouth.edu
[Append to This Answer]
Previous: (Category) Emulation
Next: (Answer) Why does dynamic loading not work in perl or python?
This document is: http://www.jonh.net/cgi-bin/lppcfom/fom?file=50
[Search] [Appearance]
This is a Faq-O-Matic 2.717d.
Hosted by anduin.org and SourceForge Logo