From cce49bec63c46d8dded85819225d14b6cc559dae Mon Sep 17 00:00:00 2001 From: olli Date: Mon, 19 Jun 2023 17:50:18 +0200 Subject: [PATCH] moved csv cleanup to startup --- dabo/dabo-bot.sh | 8 ++++++++ dabo/functions/get_assets.sh | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dabo/dabo-bot.sh b/dabo/dabo-bot.sh index 6df612c..cad6252 100755 --- a/dabo/dabo-bot.sh +++ b/dabo/dabo-bot.sh @@ -33,6 +33,14 @@ touch firstloop # am I the bot (important for functions used by analyze.sh echo $0 | grep -q "dabo-bot\.sh" && BOT=1 +# cleanup trashlines in asset-histories (possibly generated by kill further of this progress) +find asset-histories -name "*.csv" -type f | while read csv_file +do + csv_timestamp=$(ls --time-style='+%Y%m%d%H%M' -l "${csv_file}" | cut -d" " -f6) + sed -i "/[0-9]$(date +%Y)-/d" ${csv_file} + touch -t ${csv_timestamp} "${csv_file}" +done + # run endless loop while true do diff --git a/dabo/functions/get_assets.sh b/dabo/functions/get_assets.sh index 0ba7604..5aa9666 100644 --- a/dabo/functions/get_assets.sh +++ b/dabo/functions/get_assets.sh @@ -95,9 +95,6 @@ function get_assets { export csv_headline . /tmp/parallel - # cleanup trashlines (possibly generated by kill further of this progress) - sed -i "/[0-9]$(date +%Y)-/d" asset-histories/* - # get MSCI World Index for analysis echo "wget -q -O - https://www.boerse.de/realtime-kurse/MSCI-World/XC0009692739 | egrep 'itemprop=\"price\" content=\"[0-9]+\.[0-9]+\"' | cut -d\\\" -f6" >MSCI_WORLD_CMD g_runcmd g_retrycmd sh MSCI_WORLD_CMD >MSCI_WORLD_CMD_OUT.tmp