linux - How to convert decimal to hex in bash? -
this question has answer here:
i have decimal number in bash shell:
linux$ a=67
how print 67 hexadecimal in bash?
as bash program:
#!/bin/bash decimal1=31 printf -v result1 "%x" "$decimal1" decimal2=33 printf -v result2 "%x" "$decimal2" echo $result1 $decimal1 echo $result2 $decimal2
or directly bash shell:
el@defiant ~ $ printf '%x\n' 26 1a el@defiant ~ $ echo $((0xaa)) 170 el@defiant ~ $
Comments
Post a Comment