grep always returns "grep: conflicting matchers specified"

As you can see in the first line of the trace, the first argument grep receives is -GFh.

-G specifies regular expressions, while -F specifies fixed strings. These are of course incompatible.

It's unclear why grep would execute as grep -GFh ...., but the most likely possibility (as suggested in a comment) is probably an alias. You can verify this using alias grep, which will print whether or not grep is aliased, or type grep, which is more general (e.g. if grep is defined as a function, it will tell you that).


I had aliases that were 'stacking':

alias grep='grep --color=auto -i --perl-regexp'
alias fgrep='grep -Fi --color=auto'

Changing the 2nd one to \grep (leading backslash) makes them not stack.


I had grep set as an alias in my ~./bashrc. I was made of aware of this by smart people in the comments who noticed that grep was being called with options already set. I removed the alias for grep and everything is working great.

Tags:

Bash

Grep