I want to assign the output of a shell command to a variable.
If I directly echo the command, the code will execute correctly:
for ((i=0; i<${#result[@]}; i++)); do
echo ${result[$i]} | awk '{print $1}'
done
But, if I assign it to a variable,
size=`${result[$i]} | awk '{print $1}'`
echo $size
Or
size=$(${result[$i]} | awk '{print $1}')
echo $size
They are not working.
How can I fix it?