Convert Ascii to Its Decimal Value
There Is Online Tool That Can Convert Text to Ascii Such as This One. Would It Be Possible to Do the Same Thing in Ubuntu/Linux? E. G. Input Data: Abc Output...
There is online tool that can convert text to ASCII such as this one. Would it be possible to do the same thing in Ubuntu/Linux?
E.g.
Input data: abc
Output as ASCII: 097 098 099
3 Answers
Take a look at the old standby, od. Your ASCII to decimal would be:
echo -n abc | od -td1
See the man page for od, or "octal dump",
man od
For the many options in converting input to other forms -- hex, decimal, ASCII, char, etc.
You want to convert from ASCII symbol to its decimal value.
The complete table is on man ascii (or just ascii).
ASCII to decimal: "a" → "97"
printf "%d\n" \'a
Decimal to ASCII: "97" → "a"
printf '%b' $(printf '\\%03o' "97")
Another way to do this, with Perl's unpack:
$ echo abc | perl -lne 'print join " ", unpack("C*")'
97 98 99
More verbosely using split and ord,
$ echo abc | perl -lne 'print join " ", map { ord $_ } split //'
97 98 99