Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
1  
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

3 Answers 3

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
2  
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
4  
If the command grep --help gives the invalid option error, then this is not an answer. –  gertvdijk Jan 28 '13 at 12:52

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

Reference

Helped me.

share|improve this answer

Your Answer

 
discard

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.