Unix-使用Grep获取不匹配的行 [英] Unix- Using Grep to get unmatched lines

查看:183
本文介绍了Unix-使用Grep获取不匹配的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是unix的新手.我想从文件1中复制不匹配的模式,前提是这些模式在文件2中.实际文件有1000行以上.

I am new to unix. I want to grep the unmatched pattern from a file1 provided that the patterns are in the file2. The real files are having more than 1000 lines.

示例:

File1:
Hi(Everyone)
How(u)people(are)doing?
ThanksInadvance

File2:
Hi(Every
ThanksI

必填结果:

How(u)people(are)doing?

我只希望使用grep的模式("Hi(Every").它应该从file1返回不匹配的行.

I want only the pattern to be used like ("Hi(Every") for the grep.It should return the unmatched line from file1.

推荐答案

此行适用于给定示例:

grep -Fvf file2 file1

上面使用的3个选项:

-F  makes grep do fixed-string match
-v  invert matching
-f  get patterns from file

这篇关于Unix-使用Grep获取不匹配的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆