In my script I need to set values to arrays by reading from some files so instead of:
last_price_1=$(cat ~/price/last_price_1)
last_price_2=$(cat ~/price/last_price_2)
...
last_price_10=$(cat ~/price/last_price_10)
I tried to do:
for i in {1..10}
do
echo "check: last_price_$i"
last_price_$i=$(cat ~/price/last_price_$i)
done
echo "check 1: $last_price_1"
echo "check 2: $last_price_2"
But gives error and not setting the value
check: last_price_1
test.sh: line 6: last_price_1=7896: command not found
check: last_price_2
test.sh: line 6: last_price_2=7898: command not found
...
check: last_price_10
test.sh: line 6: last_price_10=7868: command not found
check 1:
check 2: