#!/bin/bash #set -x . helpers.sh 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)" log "Latest File: _${latestFile}_" debug inputFile=temp/orderInputFile.json bzip2 -dc < "${latestFile}" > "${inputFile}" fi if [[ ! -f "${inputFile}" ]]; then throw "ERROR: Input file _${inputFile}_ does not exist." err 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; } }') log "Date-Key: _${dateKey}_" debug daysOut=$(cut -d : -f 2 <<< ${dateKey}) if [[ ${daysOut} -gt ${daysOutMax} ]]; then exit fi echo "$(date +%Y-%m-%d): ${dateKey} (${latestFile})" >> record90dayOut.log