Mandar
Mandar

Reputation: 317

grep Regex to find in specific words in a file

I have a file with contents like:

this is text file, \"value\":\"ABCD1000\" , this file contains some weird text, \"value\":\"ABDFD1000\" ...

I want extract all the values like 'value :ABDC1000'

I am using grep command as: grep -o '"value\\":\\\"[a-zA-Z0-9]+\\\"' file.name 

But it does not gives any output.

What am I doing wrong here.

I used http://regexr.com/ to check my regex and it looks correct.

Upvotes: 0

Views: 63

Answers (1)

Cyrus
Cyrus

Reputation: 88553

With GNU grep:

grep -o '\\"value\\":\\"[^\\]*\\"' file | tr -d '\\"'

Output:

value:ABCD1000
value:ABDFD1000

Upvotes: 2

Related Questions