If I run grep foo bar.txt, grep highlights each occurrence of "foo" in bar.txt. But sometimes I want to use find to determine which files grep searches. So I do something like this:
find . -iname "*.abc" | xargs grep foo
Or this:
find . -iname "*.abc" -exec grep foo {} \;
In both cases, grep correctly finds occurrences of "foo" in the specified files, but the output has no highlighting whatsoever.
How can I keep using find to choose files for grep to search without losing highlighting?
I am running Gnome Terminal 3.4.1.1 on Ubuntu 12.04, with bash as my shell.
greponly once and allow spaces in file names:find . -iname "*.abc" -print0 | xargs -0 cat | grep foo– Dennis May 25 '12 at 20:17