was wondering if anyone could help me with converting ascii to hex in bash. Example code:
#!/bin/bash STR = \"hello\" #Convert to hex HEXVAL = $STR #(in hex
$ str="hello" $ hex=$(xxd -pu <<< "$str") $ echo "$hex" 6C6C6568A6F
Or:
$ hex=$(hexdump -e '"%X"' <<< "$str") $ echo "$hex" 6C6C6568A6F
Careful with the '"%X"'; it has both single quotes and double quotes.
'"%X"'