-1

I know this question has been asked before but the proposed solutions don't work for me.

I'm trying to find the string "modelInstance.addObservers" in any file (ideally any file with the .js ending, but it's fine without this filter too) in the current directory and all subdirectories. Here's what I tried:

grep -rl "modelInstance.addObserver" .

It behaves as if the statement is incomplete, because it keeps printing blank lines when I hit enter. What is the problem?

I'm on mac.

Here's what it looks like: enter image description here

  • Quick though without testing though: find . -name * | grep "modelInstance.addObserver" . If not though, some variation as such piping a recursive find to the grep command. Maybe a potential starting point for you at least. – Pimp Juice IT Apr 28 '18 at 15:39
  • Please provide the code and/or state the errors. The text on the picture is too small for some people to read. In addition, the text on the image cannot be indexed by search engines for future visitors. – jww Sep 22 '18 at 7:02
0

There is nothing wrong: your terminal echoes typed characters when no program is prompting for input; meanwhile grep is running, but not finding any files with the matching string.

It will be a lot faster if you restrict your searches to .js files by using find:

find . -name "*.js" -exec grep -l 'modelInstance\.addObservers' {} \;

Note that I have escaped the . in the search string in order to match only a literal . and not an arbitrary character in that position.

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.