echo `cat /sys/class/block/sda2/size`*512 | bc
echo "`cat /sys/class/block/sda2/size`*512" | bc
or if you use bash or any other POSIX-like shell whose arithmetic operators work with 64bit integers, you don't even need to call bc
echo $((512*$(cat /sys/class/block/sda2/size)))bc
echo "$((512*$(cat /sys/class/block/sda2/size)))"
gives the size in byte.
The call to cat and fork (except for bash) can be optimised away with bash, ksh93 and zsh with:
echo "$((512*$(</sys/class/block/sda2/size)))"