Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Every grep command returns "grep: invalid option -- '='" [closed]

Writer Mia Lopez

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?

2

4 Answers

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

Reference

Helped me.

2

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.

2

I think you need to use:

grep -e "="
2

its because there's a file in the directory starting with -

example 1:

touch ./-mike.txt
ls
-mike.txt
grep -i blah *
grep: invalid max count

example 2:

touch ./-sike.txt
grep -i blah *
grep: invalid option -- 'k'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.

solution remove files starting with - , example:

rm ./-sike.txt
1