#!/bin/bash

[ "$1" == "" ] && exec echo "Usage: $0 <START_DATE> <END_DATE> <SERVER> <LOG> <SET_NUM> <SEARCH_STRING>"

START_DATE=$1
END_DATE=$2
SERVER=$3
LOG=$4
SET_NUM=$5
SEARCH_STRING=$6

START_DATE_TIMESTAMP=$(date -d "${START_DATE}" "+%s")
END_DATE_TIMESTAMP=$(date -d "${END_DATE}" "+%s")

DATEDIFF=$(echo "(${END_DATE_TIMESTAMP}-${START_DATE_TIMESTAMP})/86400"|bc)
#LOG_FILE_DIRECTORY
#LOG_FILE_NAME

mkdir /tmp/set${SET_NUM}_${SERVER}Server_${LOG}_${SEARCH_STRING}_${START_DATE}_${END_DATE}

for i in `seq 0 ${DATEDIFF}`; do LOGDATE=$(date -d "${START_DATE} $i days" +%Y%m%d); get_log_filter ${LOGDATE} ${LOGDATE} ${SERVER} ${LOG} | egrep ${SEARCH_STRING} > /tmp/set${SET_NUM}_${SERVER}Server_${LOG}_${SEARCH_STRING}_${START_DATE}_${END_DATE}/set${SET_NUM}_${SERVER}Server_${LOG}_${SEARCH_STRING}_${LOGDATE}.log; done;

#for i in `seq 0 50`; do todate=$(date -d "20161018 $i days" +%Y%m%d); get_log_filter ${todate} ${todate} Zone Item | grep '10001810' > /tmp/set1_ZoneServer_Item_10001810_20161018_20161207/set1_ZoneServer_Item_10001810_${todate}.log; done;
