【发布时间】:2012-03-03 14:17:59
【问题描述】:
你好 bash 初学者问题。我想查看多个文件,找到包含搜索词的行,计算此列表中唯一行的数量,然后打印到 tex 文件中:
- 输入文件名
- 使用的搜索词
- 唯一行数
因此,使用搜索词“Stop_gained”的文件“Firstpredictoroutput.txt”的示例输出行将是:
Firstpredictoroutput.txt Stop_gained 10
我可以使用以下方法获取单个文件的唯一计数:
grep 'Search_term' inputfile.txt | uniq -c | wc -l | >>output.txt
但我对使用 bash 在管道中实现循环还不够了解。 我所有的输入文件都以 *predictoroutput.txt 结尾
非常感谢任何帮助。
提前致谢,
鲁巴尔
【问题讨论】:
标签: linux grep pipeline uniq wc