33 lines
995 B
Bash
33 lines
995 B
Bash
|
|
#!/bin/bash
|
||
|
|
#set -x
|
||
|
|
IFS=$'\0'
|
||
|
|
|
||
|
|
daysOutMin=90
|
||
|
|
daysOutMax=91
|
||
|
|
|
||
|
|
inputFile="$1"
|
||
|
|
latestFile="$1"
|
||
|
|
if [[ "" == "$inputFile" ]]; then
|
||
|
|
latestFile="$(ls data/`date +%Y-%m-%d`/*SPY* | sort | tail -n 1)"
|
||
|
|
systemd-cat -t "`basename $0` $1" -p debug <<< "Latest File: _${latestFile}_"
|
||
|
|
inputFile=temp/orderInputFile.json
|
||
|
|
bzip2 -dc < "${latestFile}" > "${inputFile}"
|
||
|
|
fi
|
||
|
|
if [[ ! -f "${inputFile}" ]]; then
|
||
|
|
errMsg="ERROR: Input file _${inputFile}_ does not exist."
|
||
|
|
systemd-cat -t "`basename $0` $1" -p err <<< ${errMsg}
|
||
|
|
>&2 echo "${errMsg}"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
dateKey=$(jq -r '.callExpDateMap | keys | .[]' temp/orderInputFile.json | sort -r -t ":" +2 | awk -F ":" -e '{theDay=$2; if (theDay < '${daysOutMin}') { print lastDay; exit; } else { lastDay=$0; } }')
|
||
|
|
systemd-cat -t "`basename $0` $1" -p debug <<< "Date-Key: _${dateKey}_"
|
||
|
|
|
||
|
|
daysOut=$(cut -d : -f 2 <<< ${dateKey})
|
||
|
|
if [[ ${daysOut} -gt ${daysOutMax} ]]; then
|
||
|
|
exit
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "$(date +%Y-%m-%d): ${dateKey} (${latestFile})" >> record90dayOut.log
|
||
|
|
|