我有一个文件,内容如下:
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
关于regex - grep Regex 在文件中查找特定单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35094660/