a question about GREP

Jerry greenmt at gmail.com
Fri Mar 23 16:33:05 EDT 2007


Scott,

Thank you for your solution. But it didn't work on system. :-(

Also, doesn't Grep stand for "global regular expression print"?

Zhao

On 3/23/07, Scott A. Valcourt <sav at unh.edu> wrote:
>
> Zhao-
>
> Grep stands for "global replace", though it is most often used as a global
> find of a text pattern in UNIX.
>
> >I'm asking this question, because I'm trying to do the following thing:
> >
> >Find out all plain text files whose file names contain "out" and whose
> contents containing "zip" (in the form of whole word),  and then output
> these files names to a file called zip.txt. (These plain text files are
> located in the sub-directories at different levels)
>
> Well, one way to do this in UNIX is really of the following:
>
> grep -r "zip" *out*.* > zip.txt
>
> I think this is what you want to do.
>
> -Scott
>
> At 03:41 PM 3/23/2007, you wrote:
> >Hi,
> >
> >The manual of "grep" command on Red Hat states that:
> >
> > -R, -r, --recursive
> >             read all files in each directory, recursively, this is
> equivalent to -d recurse option
> >
> >      --include=PATTERN     recurse in directories only searching file
> matching PATTERN
> >      --exclude=PATTERN     recurse in directories skip file matching
> PATTERN
> >
> >For the --include or --exclude option, what is "file matching PATTERN"
> supposed to mean? I supposed it means "file name" match PATTERN, not "file
> content" match patten, am I right?
> >
> >I'm asking this question, because I'm trying to do the following thing:
> >
> >Find out all plain text files whose file names contain "out" and whose
> contents containing "zip" (in the form of whole word),  and then output
> these files names to a file called zip.txt. (These plain text files are
> located in the sub-directories at different levels)
> >
> >I tried the following 2 lines of commands to try to achieve the goal
> above, but neither worked. Anyone cares to spot the error? I suspect most
> likely it's because my usage/understanding of --include option is wrong.
> >
> >grep -Hwli -r --include=out "zip" *  > zip.txt
> >
> >grep -Hwli --include=out "zip" * > zip.txt
> >
> >Sorry if this question sounds stupid.
> >
> >Thank you for your time.
> >
> >Zhao
> >_______________________________________________
> >gnhlug-discuss mailing list
> >gnhlug-discuss at mail.gnhlug.org
> >http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
>
> -Scott Valcourt                         email:  sav at unh.edu
> Computer Science Department            phone:  (603) 862-4489
> University of New Hampshire            fax:    (603) 862-3493
> 310 Nesmith Hall
> Durham, NH 03824
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20070323/a342c55d/attachment.html


More information about the gnhlug-discuss mailing list