2

I am trying to do a directory-wide search for specific strings in JSON files. The only problem is that these JSON files are only one line, so when I cat all of them, all strings occur a magical "1" time...since there's only one line even when I string them all together.

An easy solution, which I see a lot (here and here), is grep -o. Only problem is it doesn't come standard on my Gitbash. I solved my immediate problem by just installing the latest Cygwin. However, I'm wondering if there was an easier/more granular solution. Is it possible to do the equivalent of "apt-get install" or similar on Gitbash? Or can someone explain to me a quick-and-dirty way to extract and install the tar file in Gitbash?

Community
  • 1
  • 1
ZebGir
  • 123
  • 1
  • 7
  • I'm sure there's some good reason for grepping a JSON file, but do you know about [jq](http://stedolan.github.io/jq)? – pak Dec 17 '14 at 21:20
  • Thanks @pak that will be really helpful going forward! – ZebGir Dec 24 '14 at 12:38

1 Answers1

1

The other approach is to:

  • use a cmd session (using the git-cmd.bat which packaged with Git for Windows)
  • use the grep included Gnu for Windows, which supports the -o option (and actually allow you to use most of the other Unix commands that your script might be currently using)
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Option #2 FTW! Thanks a lot VonC! Best part is I don't even need to open a Cygwin or bash window. I can do it all from the same CMD window. Awesome. Option #1 didn't seem to work. Maybe I just need the new Git for Windows. I can't find it in my Program Files/Git folder, and when I copied the file or text into a file in said folder, I got the same error: grep: invalid option -- o – ZebGir Dec 12 '14 at 13:11