I have a json file from where I want to get the value of two items which are in an array using grep. Let's say I'm trying to get data from values foo and bar, the problem is that baralso matches megabarso I have to grep it with option -w.
The problem comes when trying to find them at the same time, as I have to grep for one value OR the other.
From this question, I managed to get a bit closer to what I'm looking for but my result was something like:
grep -E '(foo|-w bar)' file
"foo": "59766",
"foo": "59770",
"foo": "59774",
"foo": "59778",
"foo": "59782",
"foo": "59786",
Any idea on how to do it?
grepcall under all circumstances? – phk May 27 '16 at 12:00fooand in the next linebarso I can work with them later – sysfiend May 27 '16 at 12:01jqorjsonpipeor use a language (likeperlorpython) which has good json-parsing libraries. – cas May 27 '16 at 14:56