Ubuntu – grep -r “pattern” not responding

command linegrep

grep version is 2.10, and it does not respond anything, even on a small set of small files, while the same line on another Ubuntu machine works fine where grep version is 2.16…

The command is:

grep -r "myVariable"

Instead of returning nothing, or some file names and lines, like this:

path/to/file.c:     myVariable++;
path/to/file2.c:    int myVariable;

The command shell stays busy and I have to halt it using ctrl+C

What is the problem or how do I investigate it?

Best Answer

Since you don't specify any input file, grep waits for you to provide input data on its standard input.

The behavior where -r will use the current directory by default is non-standard (in fact, -r itself is), and was introduced in GNU grep 2.11.

Related Question