[英]grep Regex to find in specific words in a file
我有一個內容如下的文件:
this is text file, \"value\":\"ABCD1000\" , this file contains some weird text, \"value\":\"ABDFD1000\" ...
我想提取所有值,例如'value:ABDC1000'
I am using grep command as: grep -o '"value\\":\\\"[a-zA-Z0-9]+\\\"' file.name
但是它沒有任何輸出。
我在這里做錯了。
我使用http://regexr.com/檢查我的正則表達式,它看起來正確。
使用GNU grep:
grep -o '\\"value\\":\\"[^\\]*\\"' file | tr -d '\\"'
輸出:
value:ABCD1000 value:ABDFD1000
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.