  | |  | About grep | About grep 2004-01-19 - By Ben Yau
Back
> >
> > 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 "
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@(protected)?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
|
|
 |