0

Need to find this string "key" : " recursively in all files in the current directory.

I used the below command and it didn't work.

grep -i -R " \"key\":\" " .
  • 1
    Please provide an example of the input, the desired output, and the exact meaning of "it didn't work". – RalfFriedl Sep 28 '18 at 18:16
  • An error message / description would be nice. – RudiC Sep 28 '18 at 18:17
  • "key" : " is the input, and grep -i -R " \"key\":\" " / not printing any output – itgeek Sep 28 '18 at 18:25
2

That may be because " \"key\":\" " is not the pattern that represents "key" : ", as there's a space in the pattern before \"key. Try:

grep -i -R "\"key\":\" " .

Or to simplify it and make more readable:

grep -iR '"key" : ' .
1
find . -type f -exec grep -rl 'key" : ' {} +

Use -r instead of -R, because -R follows symlinks when descending directories, while -r doesn't.

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.