I'm a Linux newbie and have copied a bash script that extracts values from a XML. I can echo the result of a calculation perfectly, but assigning this to a variable doesn't seem to work.
#!/bin/bash
IFS=$'\r\n' result=(`curl -s "http://xxx.xxx.xxx.xxx/smartmeter/modules" | \
xmlstarlet sel -I -t -m "/modules/module" \
-v "cumulative_logs/cumulative_log/period/measurement" -n \
-v "point_logs/point_log/period/measurement" -n | \
sed '/^$/d' `)
# uncomment for debug
echo "${result[0]}"*1000 |bc
gas=$(echo"${result[0]}"*1000 |bc)
echo "${result[0]}"*1000 |bc
Gives me the result I need, but I do not know how to assign it to a variable.
I tried with tick marks:
gas=\`echo"${result[0]}"*1000 |bc\`
And with $(
Can somebody point me in the right direction?