Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Re: UNIX command to search subdirs for text in a file
  1997-01-13  5:00 UNIX command to search subdirs for text in a file Jeff Shervey
@ 1997-01-13  5:00 ` Mark Sirota
  1997-01-14  5:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Sirota @ 1997-01-13  5:00 UTC (permalink / raw)
  To: Jeff Shervey


Jeff Shervey wrote:
> With DEC UNIX 3.2 how can I search a bunch of subdirectories for a
> certain file that contains certain text.
> I'm trying this command with no luck:
> 
> find . -name *.sql -print | grep -i "duplicate" *.pls

Close.  Try:
	find . -name \*.sql -print | xargs grep -i duplicate /dev/null

The /dev/null is to ensure that grep will tell you the filename.
Without it, if the last call to grep has only one file, you won't
know the filename.
-- 
Mark Sirota, Network Systems Engineer
University of Pennsylvania, Information Systems and Computing
msirota@isc.upenn.edu, 215/573-7214



^ permalink raw reply	[flat|nested] 7+ messages in thread

* UNIX command to search subdirs for text in a file
@ 1997-01-13  5:00 Jeff Shervey
  1997-01-13  5:00 ` Mark Sirota
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Jeff Shervey @ 1997-01-13  5:00 UTC (permalink / raw)



With DEC UNIX 3.2 how can I search a bunch of subdirectories for a certain
file that contains certain text.
I'm trying this command with no luck:

grep -i "duplicate" | find . -name *.sql -print

I've also tried:

find . -name *.sql -print | grep -i "duplicate" *.pls

Thank you,
jeff.shervey@us.landisstaefa.com

-- 
These comments do not necessarily reflect the views of Landis & Staefa, Inc.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: UNIX command to search subdirs for text in a file
  1997-01-13  5:00 UNIX command to search subdirs for text in a file Jeff Shervey
  1997-01-13  5:00 ` Mark Sirota
  1997-01-14  5:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
@ 1997-01-14  5:00 ` Steve Strange USG
  1997-01-14  5:00 ` Kenneth Miller
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Steve Strange USG @ 1997-01-14  5:00 UTC (permalink / raw)



In article <01bc018d$8f170bc0$17ee1bac@usbgrjeff> "Jeff Shervey" <jeff.shervey@us.landisstaefa.com> writes:

>   With DEC UNIX 3.2 how can I search a bunch of subdirectories for a certain
>   file that contains certain text.
>   I'm trying this command with no luck:
>
>   grep -i "duplicate" | find . -name *.sql -print
>
>   I've also tried:
>
>   find . -name *.sql -print | grep -i "duplicate" *.pls

How about something like

find . -name "*.sql" -print | xargs egrep "duplicate"

	Steve
--
Steve Strange						strange@zk3.dec.com
Digital Equipment Corporation, Nashua, NH		     (603) 881-0595
Digital UNIX Filesystem Development



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: UNIX command to search subdirs for text in a file
  1997-01-13  5:00 UNIX command to search subdirs for text in a file Jeff Shervey
                   ` (2 preceding siblings ...)
  1997-01-14  5:00 ` Steve Strange USG
@ 1997-01-14  5:00 ` Kenneth Miller
  1997-01-14  5:00 ` Gleb O. Raiko
  1997-01-15  5:00 ` Juergen Fuhrmann
  5 siblings, 0 replies; 7+ messages in thread
From: Kenneth Miller @ 1997-01-14  5:00 UTC (permalink / raw)



Steve Strange USG <strange@zk3.dec.com> writes:

>> find . -name *.sql -print | grep -i "duplicate" *.pls

> How about something like

> find . -name "*.sql" -print | xargs egrep "duplicate"

find . -name \*.sql -exec fgrep -i duplicate "{}" \;

</flex>

-- 
________________________________________________________________________
                               Kenneth Miller <kemiller@hcs.harvard.edu>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: UNIX command to search subdirs for text in a file
  1997-01-13  5:00 UNIX command to search subdirs for text in a file Jeff Shervey
  1997-01-13  5:00 ` Mark Sirota
@ 1997-01-14  5:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
  1997-01-14  5:00 ` Steve Strange USG
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Alan Rollow - Dr. File System's Home for Wayward Inodes. @ 1997-01-14  5:00 UTC (permalink / raw)




In article <01bc018d$8f170bc0$17ee1bac@usbgrjeff>, "Jeff Shervey" <jeff.shervey@us.landisstaefa.com> writes:
>
>With DEC UNIX 3.2 how can I search a bunch of subdirectories for a certain
>file that contains certain text.

find . -name '*.sql' -print | xargs grep -i duplicate /dev/null

Starting at the current directory, find search for all the files
with names of the form <anything>.sql and print the names to
stdout.  This is written a copy xargs which collects as many
names as will fit on a command line and executes the command
"grep -i ..." with that file list.  The use of /dev/null as
the first name of the name ensures that grep will always print
the file name, since it typically doesn't if there is only one
file name in the list.  THere may be a grep option to provide
this feature.

If you're interested in what your commands were actually trying
to do...

>I'm trying this command with no luck:
>
>grep -i "duplicate" | find . -name *.sql -print

Do an case insensitive search for the string duplicate reading
from stdin and pipe that to the indicated find command.  Not
that find ever reads anything from stdin.

>
>I've also tried:
>
>find . -name *.sql -print | grep -i "duplicate" *.pls

Find all the indicated names and write them to grep's stdin.  Were
it not for the *.pls, this would search the file *names* for the
text "duplicate".  But since this grep has been handed a file
wildcard of *.pls, that will be expanded by the shell and those
files will be used instead of the text from stdin.

It is also worth noting that the sequence "-name *.sql" won't
search for the names of the form <anthing>.sql.  The shell does
the expansion of *.sql so the -name option will get the first
of that expansion and the rested will be treated by find as
options, which it will probably complain about.  For example,
if you had a.sql and b.sql, find would see:

find . -name a.sql b.sql -print

By quoting '*.sql' the shell won't expand it and find will know
what to make of the wildcard.

>
>Thank you,
>jeff.shervey@us.landisstaefa.com
>
>-- 
>These comments do not necessarily reflect the views of Landis & Staefa, Inc.
>
--
Alan Rollow				alan@nabeth.cxo.dec.com




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: UNIX command to search subdirs for text in a file
  1997-01-13  5:00 UNIX command to search subdirs for text in a file Jeff Shervey
                   ` (3 preceding siblings ...)
  1997-01-14  5:00 ` Kenneth Miller
@ 1997-01-14  5:00 ` Gleb O. Raiko
  1997-01-15  5:00 ` Juergen Fuhrmann
  5 siblings, 0 replies; 7+ messages in thread
From: Gleb O. Raiko @ 1997-01-14  5:00 UTC (permalink / raw)



Jeff Shervey wrote:
: 
: With DEC UNIX 3.2 how can I search a bunch of subdirectories for a 
: certain
: file that contains certain text.
: I'm trying this command with no luck:
: 
: grep -i "duplicate" | find . -name *.sql -print
: 
: I've also tried:
: 
: find . -name *.sql -print | grep -i "duplicate" *.pls

Normally, I use

find . -name \*.sql -exec egrep -i "duplicate" {} \; -print

: 
: Thank you,
: jeff.shervey@us.landisstaefa.com
: 
: --
: These comments do not necessarily reflect the views of Landis & 
: Staefa, Inc.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: UNIX command to search subdirs for text in a file
  1997-01-13  5:00 UNIX command to search subdirs for text in a file Jeff Shervey
                   ` (4 preceding siblings ...)
  1997-01-14  5:00 ` Gleb O. Raiko
@ 1997-01-15  5:00 ` Juergen Fuhrmann
  5 siblings, 0 replies; 7+ messages in thread
From: Juergen Fuhrmann @ 1997-01-15  5:00 UTC (permalink / raw)



strange@zk3.dec.com (Steve Strange USG) writes:

> 
> In article <01bc018d$8f170bc0$17ee1bac@usbgrjeff> "Jeff Shervey" 
> <jeff.shervey@us.landisstaefa.com> writes:
> 
> >   With DEC UNIX 3.2 how can I search a bunch of subdirectories 
> >   for a certain
> >   file that contains certain text.


There is glimpse -  see http://glimpse.cs.arizona.edu.  It indexes all
your files and speeds up this  kind of searches  a lot. I also managed
to get it called from emacs like grep.

Juergen


-- 
                                                 Dr. Juergen Fuhrmann      
                                       mailto:fuhrmann@wias-berlin.de
                               http://hyperg.wias-berlin.de/~fuhrmann
                         Numerical Mathematics & Scientific Computing
    Weierstrass Institute for Applied Analysis and Stochastics Berlin
SOMETHING IS ROTTEN IN THIS AGE OF HOPE heiner mueller hamletmaschine



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1997-01-15  5:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-01-13  5:00 UNIX command to search subdirs for text in a file Jeff Shervey
1997-01-13  5:00 ` Mark Sirota
1997-01-14  5:00 ` Alan Rollow - Dr. File System's Home for Wayward Inodes.
1997-01-14  5:00 ` Steve Strange USG
1997-01-14  5:00 ` Kenneth Miller
1997-01-14  5:00 ` Gleb O. Raiko
1997-01-15  5:00 ` Juergen Fuhrmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox