On Mon, Feb 21, 2011 at 04:54:40PM +0100, Alexander Schrijver wrote:
| On Mon, Feb 21, 2011 at 01:34:51PM +0100, Pascal Stumpf wrote:
| > Implement a -H flag for grep, useful for combining e.g. find and grep.
|
| -o used to do this but has been removed. (See the commit logs for the reason,
i
| forgot it)
|
| grep(1) only prints the filename when it receives more then 1 filename as
| arguments. Thus, when you do this:
|
| $ find . -name '*.c' -exec grep bla {} \;
|
| It doesn't print the filename.
|
| But when you use xargs(1), like Bret suggests it does.
It does not when there's only one file matching the find-experssion
(which is unclear when using find | xargs grep).
[weerd@despair] $ find . -name pi.c
./pi.c
[weerd@despair] $ find . -name pi.c | xargs grep main
main(int argc, char *argv[]) {
Paul 'WEiRD' de Weerd
--
>++++++++[<++++++++++>-]<+++++++.>+++[<------>-]<.>+++[<+
+++++++++++>-]<.>++[<------------>-]<+.--------------.[-]
http://www.weirdnet.nl/