[Herts] re: Top Tips

Neil Youngman n.youngman at ntlworld.com
Wed Feb 18 18:24:31 GMT 2004


On Wednesday 18 Feb 2004 12:21 am, Mr. Spock wrote:
> On Tue, Feb 17, 2004 at 12:59:20AM +0000, Ian Gregory wrote:
> > In a previous email Mr Spock suggested we post top tips for
> > working with the dreaded (to those coming from Windoze anyway)
> > command line, well here are a couple:
> >
> > 1)
> > Say you want to find all files in /etc (or any subdirectory of
> > /etc) that have a .foo extension and have been modified in the
> > last 3 days. Well, "find" is your friend:
> >
> > find /etc -type f -name \*.foo -mtime 3
>
> Excellent. I knew there must be a way of finding files within
> directories like grep looks through a single file. Maybe grep
> can be persuaded to use wildcards to scan a directory (tree);
> I'll have to read up on that.

Wildcards are normally interpreted by the shell, so need to be quoted. it 
sounds as though you are looking for something like

find /path/to/dir \( -name '*.jsp' -o -name '*.java' ) -print | xargs grep RE

to search some directories for the regexp RE in JSP or java source files. The 
-print can be omitted on linux, but I keep it in for portability.

Neil Youngman




More information about the Herts mailing list