I have file which has contents like:
--------------------------------
service=serviceX
time=100ms
PARAMS={"data"=>"{\"id\":1,\"items\":[{\"quantity\":1,\"name\":\"itemName1\"
,\"quantity\":2,\"name\":\"itemName2\"}]}
------------------------------------------------
--------------------------------
service=serviceX
time=200ms
PARAMS={"data"=>"{\"id\":2,\"items\":[{\"quantity\":2,\"name\":\"itemName3\"
,\"quantity\":2,\"name\":\"itemName4\"}]}
------------------------------------------------
--------------------------------
service=serviceX
time=300ms
PARAMS={"data"=>"{\"id\":3,\"items\":[{\"quantity\":1,\"name\":\"itemName5\"
,\"quantity\":2,\"name\":\"itemName6\"}]}
------------------------------------------------
I am trying to find all the items in listed in the file.
My query looks like
grep -o 'name\\":\\"[^\\]*\\"' | tr -d '\\"'
and the output is
name:itemName1
name:itemName2
name:itemName3
name:itemName4
name:itemName5
name:itemName6
I want the output like:
id:1
name:itemName1
name:itemName2
id:2
name:itemName3
name:itemName4
id:3
name:itemName5
name:itemName6
I am new to linux and not sure how to grep for multiple words in a single query.
No comments:
Post a Comment