In bash, I wish I could output sum of two input values, all the input and output string represented in hex format as follows.
This is what I want to do.
$ script1 0x80200000 0x800
sum = 0x80200800
$
How should I write the script 'script1' for this? Of course this doesn't work.
sum = $1 + $2
echo "sum = " $sum
You can use arithmetic expansion, which supports
0x
hex values but outputs in base 10, and print in hex usingprintf
: