Bash 使用sed解析鱼眼日志的问题

Bash 使用sed解析鱼眼日志的问题,bash,awk,sed,Bash,Awk,Sed,我正在分析日志,根据错误,我希望找到在过去7天内导致以下错误的列表存储库: 2016-09-21 14:57:11,234 WARN - Exception during FishEye Incremental Indexing of TEST-REPO1: com.cenqua.fisheye.config.ConfigException: com.atlassian.fisheye.dvcs.handler.DvcsProcessException: Error while communi

我正在分析日志,根据错误,我希望找到在过去7天内导致以下错误的列表存储库:

2016-09-21 14:57:11,234 WARN  - Exception during FishEye Incremental Indexing of TEST-REPO1: com.cenqua.fisheye.config.ConfigException: com.atlassian.fisheye.dvcs.handler.DvcsProcessException: Error while communicating with VCS: GitLab: The project you were looking for could not be found.

2016-09-21 15:07:23,379 WARN  - Exception during FishEye Incremental Indexing of TEST-REPO2: com.cenqua.fisheye.config.ConfigException: com.atlassian.fisheye.dvcs.handler.DvcsProcessException: Error while communicating with VCS: GitLab: The project you were looking for could not be found.
为了得到它,我使用sed:

sed -n "/$last_day/,/$current_date/p" /home/atlassian/crucible.data/var/log/fisheye.out | grep -i "project you were looking" | awk '{ print $11 }' | awk '!x[$0]++'
但我得到了:

TEST-REPO1:
TEST-REPO2:
you
found.
因此,我希望:

TEST-REPO1
TEST-REPO2
您当前的日志输入文件是
21-09-2016
到今天已
159
天了
27-02-2017
,因此使用上述命令,您不会得到任何输出,以检查命令是否有效。您可以在下面进行尝试

awk -F'[: ]' -v l="$(date +'%Y-%m-%d' -d' 159 days ago')" '
     /project you were looking/ && $1>=l && !seen[$14]++{
       print $14
    }' log

你显示的输入文件就是这个?你的结果看起来在这些行之后还有其他东西。我也不明白你为什么使用
| awk'!最后是x[$0]+'
。至于
sed
,如果你想显示某个日期的所有内容,你可以使用
sed-n/$last\u day/,$p“
(也就是说,你不需要
$current\u date
)。@vdavid是的,输入文件就是这样,如果使用sed-n/$last\u day/,$p“我有错误:sed:-e表达式#1,字符13:意外的”,“我的坏,”,我应该逃过$code符号:
sed-n/$last\u day/,\$p“
。不过,我很高兴你找到了答案。这正是我想要的!谢谢
awk -F'[: ]' -v l="$(date +'%Y-%m-%d' -d' 159 days ago')" '
     /project you were looking/ && $1>=l && !seen[$14]++{
       print $14
    }' log