Black Friday 2025 – NPI EA (cat = Baeldung on Linux)
announcement - icon

Yes, we're now running our Black Friday Sale. All Access and Pro are 33% off until 2nd December, 2025:

>> EXPLORE ACCESS NOW

Baeldung Pro – Linux – NPI EA (cat = Baeldung on Linux)
announcement - icon

Learn through the super-clean Baeldung Pro experience:

>> Membership and Baeldung Pro.

No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.

Partner – Orkes – NPI EA (tag=Kubernetes)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

1. Overview

One of the best things about Linux is that we can perform most operations using commands only. A good example of such operations is character conversions.

In this quick tutorial, we’ll discuss some of the ways to convert a hex character to ASCII from the command line.

2. Using the printf Command

The printf command formats and prints the data on the console. We can use this command to convert a character from hex to ASCII:

$ printf '\x4E'
N

The ASCII value of character N is 78, which is equivalent to 4E in hexadecimal. In this example, we’re simply using the \x format specifier to represent a hex number.

3. Using the echo Command

The echo command also supports various format specifiers. So, we can use it for character conversion:

$ echo -e "\x4E"
N

Note that we’ve used the -e option with the echo command. It enables interpretation of the escape sequences.

4. Using the dc Command

Alternatively, we can use the dc command to convert a character from hex to ASCII. The dc stands for Desk Calculator. This command accepts the input in postfix notation form:

$ echo "16i 4E P" | dc
N

In the above example:

  • i represents the input radix. The value 16i is used for the hex radix.
  • P represents the Print command of dc.

5. Using the xxd Command

The xxd command can generate a hex dump from a given input or reverse a hex dump given as input. We can use the reverse operation of this command for our character conversion:

$ echo 4E | xxd -r -p
N

In the above example:

  • -r option performs a reverse operation and converts the hex value to binary
  • -p option prints the result in a plain-text format

6. Conclusion

In this article, we discussed various practical examples to convert a hex character to ASCII. First, we saw examples of the printf and echo commands. Then, we used a dc command. Finally, we saw the example of the xxd command. We can use these commands in day-to-day life to boost our productivity.