I have a script that searches logs directory using grep command, below is the command.
export CMD="grep -ie '.*${RUN_DATE}.*${MESSAGE_TO_SEARCH}' ${LOG_FILE_PATH}/${LOG_FILE} | awk -F 'addInfo' '{print \$2;}' | sed '/^$/d'"
Now RUN_DATE is any date on which the script is run.
MESSAGE_TO_SEARCH is any message that we are searching in logs file.
It is declared before starting the script.
I want to modify the script that it searches between TO and FROM time, for eg:
FROM_TIME=2016-08-28 13:30:00 and
TO_TIME=2016-08-29 17:00:00
So the script should give logs that lies within this time only.
I tried the following by using passing dates as regex, but it didn't work.
export CMD="grep -ie '.*[${FROM_DATE}-${TO_DATE}].*${MESSAGE_TO_SEARCH}' ${LOG_FILE_PATH}/${LOG_FILE} | awk -F 'addInfo' '{print \$2;}' | sed '/^$/d'"
Please suggest correct method. Thanks
EDIT1: Please tell me a way i can do this, if regex is not appropriate for it.