cat 文件或标签和 xargs grep 文件中的标签
我认为这只是一个简单的命令,但我根本无法找到解决方案
我想使用标签(由多行分隔)
File1
来捕获一个文件aaa
bbb
ded
,然后将这些标签(逐行)grep 到一个文件中,我们称之为 TargetFile
我所做的如下:
cat File1 | xagrs grep {} TargetFile
它不会对 TargetFile 执行 grep 操作。我该怎么做呢?
我目前正在使用 mobaxterm
I think it is a simple command only but i simply could not come to a solution
I would like to cat a file with tags (separated by many lines)
File1
aaa
bbb
ded
and then grep those TAGS(line by line) to a single file, lets call it TargetFile
What I have done is the following:
cat File1 | xagrs grep {} TargetFile
It does not do a grep on TargetFile. How can I do it?
I am using mobaxterm
at the moment
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
另请注意,没有使用 Cat 的无用用途。
Note also the absence of a Useless Use of Cat.
像往常一样,不止一种方法可以做到这一点:
as usual more than one way to do it:
根据文件的大小,这将运行得更快:
如果 File1 中的标签数量小于可以并行运行的进程数量,则 TargetFile 将仅从磁盘读取一次。如果 TargetFile 大于磁盘缓存,这可能是个好主意。
要了解有关 GNU Parallel 的更多信息,请观看介绍视频:http://www.youtube.com/watch? v=OpaiGYxkSuQ
Depending on the size of the files this will run faster:
If the number of tags in File1 is smaller than the number of processes you can run in parallel, then TargetFile will only be read once from disk. If TargetFile is bigger than your disk cache the this is probably a good idea.
To learn more about GNU Parallel see the intro video: http://www.youtube.com/watch?v=OpaiGYxkSuQ
好吧,我想我在其他论坛搜索后找到了答案
well I think i found the answer after searching in other forums