1754325 Members
2482 Online
108813 Solutions
New Discussion юеВ

Hex to char

 
Jose M. del Rio
Frequent Advisor

Hex to char

Hi:
I would like to write a shell script to translate a string of hexadecimal characters into its ASCII representation (e.g. "41424241" into "ABBA").
Any help?
Thanks.
2 REPLIES 2
Tim D Fulford
Honored Contributor

Re: Hex to char

Hi, I tend to use ksh which definitely works but I recon this should work for all shells:

# Convert Dec --> Hex
printf "%X\n"
# This will give capital hex e.g A (== 10 dec)
printf "%x\n"
# This will give lower cace e.g a (== 10 dec)

# Convert Hex --> Dec
printf "%d\n" 0x
# Remember to put on the leading 0x to show it is hex

simple

Tim
-