[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: a grep question



On Tue, Mar 05, 2002 at 12:52:44PM -0800, justin cunningham wrote:
> Hi, I read through man on find and grep and am trying to search for an
> ip in some files contained in folders but every time I type in grep
> options it just hangs.  What am I doing wrong?

We don't know unless you show us the precise command line you're using.
Cut'n'paste from your terminal.

> Conversely i can go into /site.com/cgi-bin then cat any.cgi | grep
> 10.0.0.1 

You could also

$ grep '10.0.0.1' any.cgi

...you don't strictly need the cat command.

> and will get the desired result but instead of doing this for 'every
> file' in 'every folder' I want to search for the 10.ip in the files from
> the site's root directory.

One way:

find /path/to/cgi-bin -type f -exec grep '10.0.0.1' {} \;

(the {} and the \; are explained in the find manpage under the -exec
directive.  if you want to know the name of the file rather than getting
back the line itself, one way is to give grep the -l option.)

-- 
## Michael Jinks, IB ## JFI/MRSEC Computing ## University of Chicago ##
      Reader!  Think not that
      technical information
      ought not be called speech;  -- Anonymous, "How to decrypt a DVD"



Reply to: