7

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?

7
  • 2
    Without specifying, what's the command how can you expect someone to help you?
    – user495867
    Jan 4, 2017 at 13:36
  • the command is in the title, Ok I'll edit Jan 4, 2017 at 13:40
  • And of course pattern occurs there. Jan 4, 2017 at 13:44
  • 1
    You should specify which file(s) to search for the pattern. You can use wild cards or a single file, for example grep "alias" ~/.bashrc should produce a few lines of output (there are some aliases in the default .bashrc).
    – sudodus
    Jan 4, 2017 at 13:49
  • This means that the 2.10 version of grep does not support this feature.
    – Pilot6
    Jan 4, 2017 at 13:50

2 Answers 2

18

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.

1
  • No path, just: (standard input): Jun 14, 2018 at 6:50
1

I think you are missing file name. From the grep's man page the syntax should be as below :

grep [OPTIONS] PATTERN [FILE...]

Ex : grep -r pattern your_directory_path
1
  • I am using grep (GNU grep) 2.16. It doesn't work for me if I don't specify a file name. Jan 4, 2017 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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