[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
RE: About grep
- From: "Ben Yau" <byau cardcommerce com>
- To: <redhat-list redhat com>
- Subject: RE: About grep
- Date: Mon Jan 19 12:13:01 2004
> >
> > My personal favorite is still:
> >
> > find . -type f -exec grep 'abc' {} /dev/null \;
> >
> Why not just:
> grep -rn "abc" .
>
> Prints filenames and linenumbers, searches recursively (starting with
> ".", the current directory).
>
"find" can give you more refined control over the files you are looking for.
In John's example, he is only grepping on regular files (text files)
with -type f. Your example would also grep binary files which is something
you may not want to do. If you don't care running both, I'd combine them
find . -type f -print | xargs grep -n "abc"
I also like this becuase occasionally I also want to use -C NUM with grep
(shows NUM lines before and after the matching line)
find . -type f -print | xargs grep -n -C 3 "abc"
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]