a question about GREP
Jerry
greenmt at gmail.com
Fri Mar 23 15:41:03 EDT 2007
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.gnhlug.org/mailman/private/gnhlug-discuss/attachments/20070323/bb0f4812/attachment.html
More information about the gnhlug-discuss
mailing list