From f36485f1eb7df6c71132c2a6973e2488da783ec7 Mon Sep 17 00:00:00 2001 From: olli Date: Thu, 17 Oct 2024 17:16:59 +0200 Subject: [PATCH] sort multiple matches --- dabo/functions/currency_converter.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dabo/functions/currency_converter.sh b/dabo/functions/currency_converter.sh index b5362a7..0eacbd0 100644 --- a/dabo/functions/currency_converter.sh +++ b/dabo/functions/currency_converter.sh @@ -101,10 +101,12 @@ function currency_converter { do # search for most precise date f_line=$(egrep "^$f_currency_date_minute" "$f_histfile"*m.csv 2>/dev/null | tail -n1) - [ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_hour" "$f_histfile"*m.csv 2>/dev/null | tail -n1) - [ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_day" "$f_histfile"*h.csv 2>/dev/null | tail -n1) - [ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_month" "$f_histfile"*.csv 2>/dev/null | tail -n1) + set -x + [ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_hour" "$f_histfile"*m.csv 2>/dev/null | sort | tail -n1) + [ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_day" "$f_histfile"*h.csv 2>/dev/null | sort | tail -n1) + [ -z "$f_line" ] && f_line=$(egrep "^$f_currency_date_month" "$f_histfile"*.csv 2>/dev/null | sort | tail -n1) [ -n "$f_line" ] && f_rate=$(echo "$f_line" | cut -d, -f2) + set +x f_reverse=false if [ -n "$f_rate" ] then