4

I expected printf %s '\<octal_character_value>' to do the trick, but it doesn't:

printf %s '\101'

Outputs:

\101
4

Presumably you want %b. From help printf:

In addition to the standard format specifications described in printf(1),
printf interprets:

  %b    expand backslash escape sequences in the corresponding argument

And:

$ printf "%b\n" '\101'
A

I don't know if it works for Unicode characters in general.

0
1

You can use Awk:

$ awk 'BEGIN {print "\107"}'
G

Or the awk Velour library:

$ velour -n 'print n_chr(+n_baseconv(107, 8, 10))'
G

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.