【发布时间】:2017-06-11 17:27:32
【问题描述】:
我是 unix 脚本的新手。我有一个要求,我需要根据另一个 csv 文件中的一组字符串检查 csv 文件中的字符串。我的 file1 将具有如下值, 文件1
task desc
1 network error in there in line one.
2 data error is there in line three.
3 connection is missing from device.
4 new error is there
而file2 将有标准的查找数据
文件2
Network error
data error
connection is
file2 是静态的,我的file1 每天都在变化。我的要求是检查file1 中的每一行并检查file2 中的字符串。如果file1 中有任何新的错误条目,则需要将整行写入一个名为file3 的新文件中。这种从日志文件中检查的日常标准错误并报告新错误。例如,在我上面的示例中,输出 file3 需要如下所示。
文件3
4 new error is there
【问题讨论】:
-
grep是你的朋友。了解其选项-v、-i和-f。