How to Convert ASCII to Character in KSH

by Brian Kadigan

Ksh is an abbreviation for the Korn shell, a command interpreter for Unix and Linux operating systems. Ksh, as with all command-line interfaces, accepts typed commands from the user, executes them, and returns the output from these commands.

American Standard Code for Information Interchange is a globally-recognized standard for representing text and other characters in a numerical form that computers can recognize. Each symbol in the ASCII character set has a number associated with it -- binary, octal, decimal, or hexadecimal. In Ksh, the Unix "printf" command can be used to easily convert the number to its associated character.

1

Ensure that Ksh is installed on your system; if not, install it using the package manager specific to your system.

2

Open a Ksh window.

3

Type the following at the command prompt:

printf '\x40\n'

This example will output the "at" symbol, "@," followed by a newline ("\n"). 40 is the hexadecimal ASCII address for the "@" sign. For the particular character you want, use the character's hex address in place of "40" in the above.

Tips

  • check You can also use an octal address by typing the following, replacing "xxx" with the octal value:
  • check printf '\xxx\n'

Items you will need

About the Author

Brian Kadigan is a professional writer for various websites. He has a lifelong interest in technology, history, the hard sciences and the role of information in culture. Kadigan holds a master's degree in library and information science and has worked primarily in the legal field in research and filing positions.

Photo Credits

  • photo_camera Comstock/Comstock/Getty Images