bash文本搜索:查找一个文件的内容是否在另一个文件中 [英] bash text search: find if the content of one file exists in another file
本文介绍了bash文本搜索:查找一个文件的内容是否在另一个文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我们有两个文件:a.txt和b.txt.每个文件都有多行文本.
Say we have two files: a.txt and b.txt. Each file has multiple lines of text.
如何编写Shell脚本来检查b.txt中是否存在a.txt的所有内容?
How do I write a shell script to check if all of the content of a.txt exists in b.txt?
提示家伙们,我没注意到-q如果成功匹配将输出0.
Thx for the hints guys, i didn't noticed -q will output 0 if successfully matched.
我最终得到:
如果grep a.txt -q -f b.txt
;然后
其他
fi
推荐答案
尝试grep
cat b.txt|grep -f a.txt
这篇关于bash文本搜索:查找一个文件的内容是否在另一个文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文