1、測試數據
[root@centos79 test]# ls a.txt b.txt [root@centos79 test]# cat a.txt e k [root@centos79 test]# cat b.txt e r t d f 3 s g k i e x d f g
2、以a.txt中每一行為關鍵字,查找b.txt中匹配的行
[root@centos79 test]# cat a.txt e k [root@centos79 test]# cat b.txt e r t d f 3 s g k i e x d f g [root@centos79 test]# grep -f a.txt b.txt e r t s g k i e x
3、修改測試數據,精確匹配測試
[root@centos79 test]# cat a.txt e k [root@centos79 test]# cat b.txt ek r t d f 3 s g k i e x d f g [root@centos79 test]# grep -f a.txt b.txt ek r t s g k i e x [root@centos79 test]# grep -w -f a.txt b.txt // -w 限定精確匹配 s g k i e x