tags:

views:

3576

answers:

4

Character to value works:

$ printf "%d\n" \'A
65
$

I have two questions, the first one is most important:

  • How do I take 65 and turn it into A?
  • \'A converts an ASCII character to its value using printf. Is the syntax specific to printf or is it used anywhere else in BASH? (Such small strings are hard to Google for.)
A: 

For this kind of conversion, I use perl:

perl -e 'printf "%c\n", 65;'
mouviciel
+5  A: 

http://wooledge.org:8000/BashFAQ/071

seb
printf \\$(printf '%03o' 65) ==> A
DeletedAccount
+1  A: 

One option is to directly input the character you're interested in using hex or octal notation:

printf "\x41\n"
printf "\101\n"
Naaff
A: 

printf %x 65 => print hex value from decimal = 41

printf "\x$(printf %x 65) => print character from hex value from decimal = A

broaden