Mathematical expression result assigned to a Bash variable
问题 How do I save the result of evaluating a mathematical expression to a variable using bash? My code is the following: W1=$(bpimagelist -U -d 11/01/2013 00:00:00 -e 11/05/2013 00:00:00 -pt FlashBackup-Windows | tail -n +3 | awk '{s+=$5} END {print s/1024/1024/1024}') W2=$(bpimagelist -U -d 11/01/2013 00:00:00 -e 11/05/2013 00:00:00 -pt MS-Windows | tail -n +3 | awk '{s+=$5} END {print s/1024/1024/1024}') echo "$W1+$W2" | bc | awk '{printf "%.02f\n", $1}' Console Output: 96.86 I am looking for a