从另一个文件中的一个文件中查找模式
我正在尝试从另一个文件中的一个文件中找到模式。
文件中的模式看起来像这样:
ENSG00000203875.13
ENSG00000262691.1
ENSG00000254911.3
文件两个包含:
ENSG00000203875.13 aa aaa bbb cc
ENSG00000227782.2
ENSG00000229582.3
ENSG00000241769.7
ENSG00000245904.4
ENSG00000254823.2
ENSG00000254911.3 cc ccc ccc
ENSG00000260213.6
ENSG00000260997.1
ENSG00000261799.1
ENSG00000262691.1 bbb bbb bbb
ENSG00000267249.1
ENSG00000270012.1
ENSG00000270091.1
ENSG00000270361.1
ENSG00000271533.1
ENSG00000271833.1
ENSG00000271870.1
ENSG00000272379.1
ENSG00000272631.1
ENSG00000273066.5
ENSG00000273855.1
ENSG00000278966.2
ENSG00000279332.1
ENSG00000279407.1
ENSG00000279616.1
ENSG00000279684.1
ENSG00000279835.1
ENSG00000286181.1
ENSG00000286986.1
ENSG00000287817.1
我试图仅
ENSG00000203875.13 aa aaa bbb cc
ENSG00000254911.3 cc ccc ccc
ENSG00000262691.1 bbb bbb bbb
作为输出找到。我很确定grep -f file_one.txt file_two.txt
应该做这项工作,但是我只是将file_two的内容作为输出。我不知道我在犯什么错误。有人可以指出吗?
I'm trying to find patterns from one file in another file.
The pattern in file one looks something like this:
ENSG00000203875.13
ENSG00000262691.1
ENSG00000254911.3
File two contains:
ENSG00000203875.13 aa aaa bbb cc
ENSG00000227782.2
ENSG00000229582.3
ENSG00000241769.7
ENSG00000245904.4
ENSG00000254823.2
ENSG00000254911.3 cc ccc ccc
ENSG00000260213.6
ENSG00000260997.1
ENSG00000261799.1
ENSG00000262691.1 bbb bbb bbb
ENSG00000267249.1
ENSG00000270012.1
ENSG00000270091.1
ENSG00000270361.1
ENSG00000271533.1
ENSG00000271833.1
ENSG00000271870.1
ENSG00000272379.1
ENSG00000272631.1
ENSG00000273066.5
ENSG00000273855.1
ENSG00000278966.2
ENSG00000279332.1
ENSG00000279407.1
ENSG00000279616.1
ENSG00000279684.1
ENSG00000279835.1
ENSG00000286181.1
ENSG00000286986.1
ENSG00000287817.1
I'm trying to find only
ENSG00000203875.13 aa aaa bbb cc
ENSG00000254911.3 cc ccc ccc
ENSG00000262691.1 bbb bbb bbb
as output. I'm pretty sure grep -f file_one.txt file_two.txt
should do the job, but instead I just get the content of file_two as output. I don't know what mistake I'm making. Can anyone point it out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会做类似的事情:
I'd do something like:
您可以考虑使用
awk
方法,跟踪 file_one.txt arraya
的第一列的值,然后检查 file_two.txt 的第一列的值在数组的键中存在:输出
另一个选项使用GREP:
You might consider using an
awk
approach, keeping track of the values of the first column of file_one.txt in arraya
, and then check of the value of the first column of file_two.txt is present in the keys of the array:Output
Another option using grep: