No use perl, python, and similar.
Use printf
, a bash builtin: http://mywiki.wooledge.org/BashFAQ/071
If you want the ASCII code of a character in hex:
function ord {
printf %x "'$1"
}
ord A # 41
ord 0 # 30
The use of the single leading quote is explained here: http://pubs.opengroup.org/onlinepubs/009695399/utilities/printf.html
If the leading character is a single-quote or double-quote, the value shall be the numeric value in the underlying codeset of the character following the single-quote or double-quote.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With