<分区>
我有一个包含所有信息的日志文件。
2017-09-21 02:01:11,130 [http-nio-8080-exec-5] INFO - Inbound Message
...
...
2017-09-21 09:01:11,130 [http-nio-8080-exec-5] INFO - Inbound Message
----------------------------
ID: 6044
Address: http://localhost/serveur/Service?wsdl
Encoding: UTF-8
Http-Method: POST
...
2017-09-21 12:01:11,130 [http-nio-8080-exec-5] INFO - Inbound Message
...
我只想提取 2 个日期之间的信息。例如,如果我想要 2017-09-21 09.. 和 2017-09-21 12 之间的信息,我会得到这样的信息:
./script.sh 2017-09-21 09 2017-09-21 12
# $1 = 2017-09-21
# $2 = 09
# $3 = 2017-09-21
# $4 = 12
# $1 & 2 are date and hour to begin extract
# $3 & 4 are date and hour to finish extract
我的脚本是这样的。我不了解 shell 编程,但我尝试这样做。不幸的是,它不起作用
#!/bin/bash
beginLine = "$1 $2"
finishLine = "$3 $4"
while read fileLog.log
do
if($fileLog.log grep beginLine)
echo $fileLog.log >> extractedlog.log
fi
if($fileLog.log grep finishLine)
< extractedLog.log;
fi
done
exit 0;
谁能告诉我问题出在哪里?