[Sunhelp] Search engine

John McLeod john.mcleod at drea.dnd.ca
Thu Jun 17 06:56:39 CDT 1999


Hello Paul,

The following generic combination of find/grep
can be used for listing all the files containing
a keyword.

# uname -a
SunOS <myhost> 5.7 Generic sun4u sparc SUNW,Ultra-5_10
# find /etc -type f -exec grep -l '[uU]nix' {} \;
/etc/mail/main.cf
/etc/mail/subsidiary.cf
/etc/mail/sendmail.cf
/etc/magic
/etc/pam.conf
/etc/system
/etc/snmp/conf/enterprises.oid
/etc/snmp/conf/snmpd.conf

Hints to the command line are:
-l <-- grep outputs the name of the file if match, not line
-exec <-- when a path is found it spawns an instance of
          whatever follows this
{} <-- each found file is placed here
\; <-- an escaped semi-colon must close the -exec command
       (pipe or > could then follow this.

Hope this helps, John


Paul Khoury wrote:
> 
> This might seem more of a software/programming question than a SPARC/Solaris
> question, but I'm trying to put together some way to search through several
> thousand flies I have on my SPARC (email archives), where you can search
> for a particular word or phrase, and the program creates a listing of matching filenames.
> 
> I was thinking of using mySQL, but I know nothing about SQL (yet).
> I was also thinking of using a secondary Linux machine (x86) to do the processing,
> and use NFS (after reading some NFS faqs).
> 
> If anyone knows of such a program that's free (GNU or whatnot), please let me know.
> Thanks,





More information about the SunHELP mailing list