Integer ASCII value to character in BASH using printf


Question

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.)
1
70
5/20/2009 9:07:56 PM

One line

printf "\x$(printf %x 65)"

Two lines

set $(printf %x 65)
printf "\x$1"

Here is one if you do not mind using awk

awk 'BEGIN{printf "%c", 65}'
56
5/3/2014 12:43:33 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon