How can I get the character code using only bash, without xdd?

No use perl, python, and similar.

Answers


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.


Need Your Help

Execute a PyDev project in the Python Interactive Console?

python console pydev interactive

I'm a begginer in Python and PyDev. I recently made the "helloworld" program in PyDev. My question is: how do I execute it or open it in the interactive Python mode (in Linux terminal) I tried many