I have a requirement to have a string that has a decimal value. For example, '0 2930 0'. Now when I convert it to hex, it should say "0000 0B72 0000". I can convert the values to hex using split and obase = 16 with bc, I will get the answer as "0 B72 0". I need to get the value "0000 0B72 0000". Can anyone help shed some light on this?
Here is what I did:
s1 ='2930'
echo after converting it to hexadecimal
s=`echo "obase=16; $s1" |bc`
echo $s
source
share