From f27dbaaae4bd737c26501fa452486b1edfd3a960 Mon Sep 17 00:00:00 2001 From: olli Date: Wed, 7 Feb 2024 10:37:30 +0100 Subject: [PATCH] nicer bash code --- dabo/functions/get_vars_from_csv.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dabo/functions/get_vars_from_csv.sh b/dabo/functions/get_vars_from_csv.sh index 75c2fde..56fb74c 100644 --- a/dabo/functions/get_vars_from_csv.sh +++ b/dabo/functions/get_vars_from_csv.sh @@ -41,11 +41,10 @@ function get_vars_from_csv { get_var_from_line price 2 # get newest price from raw file if this is a non-full loop - # TODO: Nicer pure-bash code if [ ${FULL_LOOP} == 0 ] then - f_ASSET_HIST_FILE_RAW=$(echo ${f_ASSET_HIST_FILE} | sed 's/.csv$/-raw.csv/') - f_price=$(tail -n1 "${f_ASSET_HIST_FILE_RAW}" | cut -d, -f2) + readarray -d "," -t f_last_line_raw_array < <(tail -n1 "${f_ASSET_HIST_FILE/.csv/-raw.csv}") + f_price=${f_last_line_raw_array[1]} fi get_var_from_line price_change 3