5

This way I get colored output:

grep class testdata.py 

Since this gets set in my .bashrc:

alias grep='grep -n --color'

But if I search like this, I see no colored output:

find -name '*.py'  | xargs grep "class"

Has someone an idea how to enable colored output of grep if called via find ...| xargs grep?

guettli
  • 1,389

1 Answers1

8

You have to add --color explicitly because xargs doesn't use your aliases, as mentioned in the comments. So your command would look like:

find -name '*.py'  | xargs grep --color "class"
Sethos II
  • 520