more pure bash to speed up things

This commit is contained in:
olli 2023-11-11 17:33:06 +01:00
parent 5ddbebe1ae
commit bdb0f540f5

View File

@ -7,19 +7,23 @@ function get_vars_from_csv {
return 1
fi
if [ -z "${f_last_lines_array}" ]
then
mapfile -t f_last_lines_array <<< $(tail -n4 "${f_ASSET_HIST_FILE}")
fi
[ -z "${f_last_lines_array[3]}" ] && return 1
if [ -z "${f_market_performance}" ]
then
f_market_performance="-50"
fi
f_all_vars="f_market_performance=${f_market_performance}"
# read last 4 lines in array if not given
if [ -z "${f_last_lines_array}" ]
then
mapfile -t f_last_lines_array <<< $(tail -n4 "${f_ASSET_HIST_FILE}")
fi
# if there are not four lines
[ -z "${f_last_lines_array[3]}" ] && return 1
# create array of last line fields
#f_last_line="$(tail -n1 "${f_ASSET_HIST_FILE}"),${f_market_performance}"
f_last_line="${f_last_lines_array[3]}"
readarray -d "," -t f_last_line_array < <(echo "0,${f_last_line}")
@ -27,9 +31,12 @@ function get_vars_from_csv {
readarray -d "," -t f_3_last_line_array < <(echo "0,${f_last_lines_array[1]}")
readarray -d "," -t f_4_last_line_array < <(echo "0,${f_last_lines_array[0]}")
# remove f_last_lines_array
unset f_last_lines_array
f_asset=$(basename ${f_ASSET_HIST_FILE} | cut -d\. -f1)
#f_asset=$(basename ${f_ASSET_HIST_FILE} | cut -d\. -f1)
# bash-only basename
f_asset="${f_ASSET_HIST_FILE##*/}"
# basics
get_var_from_line date 1