Bash 分析日志中的条目名称

Bash 分析日志中的条目名称,bash,shell,parsing,Bash,Shell,Parsing,编写bash解析脚本是我个人的噩梦,所以我来了 服务器日志格式如下: 197 INFO Thu Mar 27 10:10:32 2014 seq_1_1..JobControl (DSWaitForJob): Waiting for job job_1_1_1 to finish 198 INFO Thu Mar 27 10:10:36 2014 seq_1_1..JobControl (DSWaitForJob): Job job_1_1_1 has finishe

编写bash解析脚本是我个人的噩梦,所以我来了

服务器日志格式如下:

197 INFO    Thu Mar 27 10:10:32 2014
    seq_1_1..JobControl (DSWaitForJob): Waiting for job job_1_1_1 to finish
198 INFO    Thu Mar 27 10:10:36 2014
    seq_1_1..JobControl (DSWaitForJob): Job job_1_1_1 has finished, status = 3 (Aborted)
199 WARNING Thu Mar 27 10:10:36 2014
    seq_1_1..JobControl (@job_1_1_1): Job job_1_1_1 did not finish OK, status = 'Aborted'
从这里,我需要解析出以下格式的字符串:

作业作业名称已完成,状态=3(已中止)

因此,从上面的输出中,我应该得到:job_1_1_1

如果我将此服务器日志作为某个命令输出,那么脚本会是什么样子


感谢xx使用
grep-p

grep -oP '\w+(?= has finished, status = 3)' file
job_1_1_1

是的,我的回答暗示:)