Error: grep: find: Is a directory

Viewed 31355

I am new to Linux and going through some tutorials and samples. I created a file called test and put alex and alexander in it. I'm trying to find instances of just alex.

If I do grep alex * I get the error:

grep: find: Is a directory.

If I do cat test | grep alex then I get (as expected)

alex
alexander (with alex in red)

Why does the first cause an error, and the second produce expected results?

5 Answers

The correct answer would be:

grep -d skip alex /etc/*

If you wanted to go through all the directories including the find directory, you can run this command:

grep alex * -r

Which will go through all the directories in your current directory recursively.

Related