如何使用linux命令提取与文本文件中特定字段匹配的文本 [英] how to extract text which matches particular fields in text file using linux commands
本文介绍了如何使用linux命令提取与文本文件中特定字段匹配的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,下面是我的文本文件
Hi below is my text file
{"Author":"john"
"subject":"java"
"title":"java cook book.pdf"}
{"title":"Php book.pdf"
"Author":"Smith"
"subject":"PHP"}
{"Author":"Smith"
"title":"Java book.pdf"}
从上述数据中,我想提取所有包含"java"单词的标题,我应该得到以下输出
from the above data i want to extract all titles which contains "java" word, i should get the following output
java cook book.pdf
Java book.pdf
请建议我
谢谢
推荐答案
GNU sed
sed -r '/title.*java/I!d;s/.*:.(.*).}$/\1/' file
java cook book.pdf
Java book.pdf
这篇关于如何使用linux命令提取与文本文件中特定字段匹配的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文