Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've already removed and reinstalled grep on Ubuntu but still the same error persists.

Whatever grep command I type I always see the following output:

grep: invalid option -- '='

Usage: grep [OPTION]... PATTERN [FILE]...

Try grep --help for more information.`

So even

grep -V

results in this error, or

grep --help

same thing!

/bin/grep has the same byte size as it does on my other identical hosts, where it works fine, so it's likely to be some environmental variable or local setting.

Any ideas?

share|improve this question
I honestly cannot tell you why, but going in and out of the bash shell a couple of times, and it's working perfectly - I'd still be interested in ideas as to why this occurred. other commands remained unaffected. – user77887 Jul 19 '12 at 1:17
probably you had an alias like grep -=. I'd suggest you to mark Jeremy's answer as the solution to the problem. – Andrea Corbellini Jan 28 '13 at 15:47

In case this isn't yet fixed, see if there is any file in the directory that starts with a '-'.


Helped me.

share|improve this answer
That was it for me! Pretty much a problem for any command that has a glob in it I guess. – a different ben Feb 6 '15 at 1:16

Sounds like you have an alias to grep, which is adding invalid arguments. Try the following:

type grep

this will tell you if the grep command is an alias or not. If it is, check your .profile, .bash_profile and .bashrc files for where this alias is defined.

share|improve this answer
thanks, yeah I tried this, using the command alias too. I am sure this was part of the answer as I noticed that there were no aliases defined on the box, whereas there should have been a few (as this box is identical to some other boxes which show their alias list correctly) I should add that the problem is no longer there, when I execute the command type grep I do get the correct alias of grep is aliased to `grep --color=auto' which of course is just allowing me to see things in colour for tired eyes :) – user77887 Jul 19 '12 at 3:57
So you're saying that it's working fine now? Did you change anything? – Jeremy Kerr Jul 19 '12 at 4:39

I think you need to use:

grep -e "="
share|improve this answer
If the command grep --help gives the invalid option error, then this is not an answer. – gertvdijk Jan 28 '13 at 12:52
This helped me, I ended up here trying to grep search a string that contained -> which gave error "grep invalid option -- >". I added -e to my command to tell grep that the next argument is a pattern and not an argument. – zeros-and-ones Apr 25 at 22:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.